Skip to content

Conversation

hnrklssn
Copy link
Contributor

This adds support for attaching safe interop wrappers to functions explicitly imported as instance methods using swift_name.

rdar://156288883

@hnrklssn
Copy link
Contributor Author

@swift-ci please smoke test

@hnrklssn hnrklssn force-pushed the swiftify-import-as-method branch from 628fc8a to c1bf742 Compare September 25, 2025 05:45
@hnrklssn
Copy link
Contributor Author

@swift-ci please smoke test

1 similar comment
@hnrklssn
Copy link
Contributor Author

@swift-ci please smoke test

Copy link
Contributor

@Xazax-hun Xazax-hun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, left some small questions/nits inline.

Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@hnrklssn
Copy link
Contributor Author

@swift-ci please smoke test

4 similar comments
@hnrklssn
Copy link
Contributor Author

@swift-ci please smoke test

@hnrklssn
Copy link
Contributor Author

@swift-ci please smoke test

@hnrklssn
Copy link
Contributor Author

@swift-ci please smoke test

@hnrklssn
Copy link
Contributor Author

@swift-ci please smoke test

let args: [ExprSyntax] = base.signature.parameterClause.parameters.enumerated()
.map { (i: Int, param: FunctionParameterSyntax) in
return pointerArgs[i] ?? ExprSyntax("\(param.name)")
if let overrideArg = pointerArgs[i] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this is a fix we want to backport to 6.2.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's probably a good idea

@hnrklssn
Copy link
Contributor Author

@swift-ci please smoke test

1 similar comment
@hnrklssn
Copy link
Contributor Author

@swift-ci please smoke test

@hnrklssn hnrklssn force-pushed the swiftify-import-as-method branch from 51c8c99 to 801f900 Compare September 30, 2025 21:00
@hnrklssn
Copy link
Contributor Author

@swift-ci please smoke test

@hnrklssn hnrklssn enabled auto-merge October 1, 2025 00:18
@hnrklssn
Copy link
Contributor Author

hnrklssn commented Oct 1, 2025

@swift-ci please smoke test

This adds support for attaching safe interop wrappers to functions
explicitly imported as instance methods using swift_name.

rdar://156288883
While we handled prepending & to MutableSpan parameters, regular
parameters that were unchanged during the transformation were not
checked for inout-ness.
Since the compiler invokation performing the macro expansion dump
redirects its stderr output, any errors are not displayed by default.
This is extra problematic for test failures in CI. By performing the
compiler invokation with -verify first, errors are shown.
@hnrklssn hnrklssn force-pushed the swiftify-import-as-method branch from 8c4e699 to f631365 Compare October 2, 2025 23:43
@hnrklssn
Copy link
Contributor Author

hnrklssn commented Oct 2, 2025

@swift-ci please smoke test windows platform

@hnrklssn hnrklssn force-pushed the swiftify-import-as-method branch from f631365 to 0c3db50 Compare October 3, 2025 22:25
@hnrklssn
Copy link
Contributor Author

hnrklssn commented Oct 3, 2025

@swift-ci please smoke test

@hnrklssn
Copy link
Contributor Author

hnrklssn commented Oct 4, 2025

@swift-ci please smoke test linux

@hnrklssn
Copy link
Contributor Author

hnrklssn commented Oct 4, 2025

@swift-ci please smoke test macos

@hnrklssn hnrklssn merged commit ed4f058 into swiftlang:main Oct 4, 2025
3 checks passed
hnrklssn added a commit to hnrklssn/swift that referenced this pull request Oct 8, 2025
…ethod

[Swiftify] Add support for free functions imported as instance methods

(cherry picked from commit ed4f058)
hnrklssn added a commit to hnrklssn/swift that referenced this pull request Oct 8, 2025
…ethod

[Swiftify] Add support for free functions imported as instance methods

(cherry picked from commit ed4f058)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants