-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Allow Swift to call objc_direct constructors #62183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -47,14 +51,23 @@ markUsed(Bar.directClassMethod2()) | |||
markUsed(bar.directProtocolMethod()) | |||
// CHECK: function_ref @[[BYTE01]]-[Bar directProtocolMethod] | |||
|
|||
// CHECK: sil [clang Bar.directProtocolMethod] @[[BYTE01]]-[Bar directProtocolMethod] : $@convention(objc_method) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should add a syntax for quoting SIL symbol names with non-identifier characters, like LLVM's @"foo bar bas"
syntax, so that the printed SIL here can still round-trip.
This looks great! It would be cool to also update the SIL printer/parser to round-trip the weird ObjC symbols, but I think it's fine to do that in a follow up. |
@swift-ci Please test |
@ellishg Any remaining concerns before I merge this? |
I agree, but I haven't looked at the SIL parser recently to know how difficult this is. If I find time I can try to follow this up.
That's all, please merge. Thanks! |
The test
See: https://ci.swift.org/job/oss-swift_tools-RA_stdlib-DA_test-device-non_executable/2480/ @ellishg Would you be available to fix it? We can disable the test for that platform for now if the fix is non-trivial. |
I'm taking a look now. I assume the fix is simple, but I'll have to run locally to verify. Feel free to disable for that platform for now. |
Import Objective-C constructors that are
objc_direct
in Swift.In #40234 we stopped importing these
objc_direct
constructors to prevent a runtime error. This pull request fixes the codegen so that they can be used correctly.