-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Typechecker] Allow bridging of Unmanaged to Objective-C for throwing functions #24135
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
cc @jrose-apple |
Thanks for picking this up! I'm worried that we won't necessarily compile this correctly, though, so can you add an execution test where a Swift thing is being called from Objective-C and the Objective-C side handles both the success and failure cases? |
(Alternately, an IRGen test, but only if you want to practice writing IRGen tests.) |
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.
Thanks! I have a bunch of FileCheck tips now on how to make this test more robust.
Thanks Jordan, I have updated the test file with your suggestions. |
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.
Heh, okay. More semantic names are nicer for maintainers, but this is good enough to run tests! …except for the return type thing.
@swift-ci Please test |
Build failed |
Build failed |
Hmm fails on iOS simulator:
I guess we don't emit |
It matters which function it is, though. I suspect the difference is going to be in all those attributes of the error parameter…at the very least the pointer size is different. It's probably worth testing locally with a 32-bit simulator (watchOS is easiest to get working) to see where else the CHECK lines are assuming pointer sizes! |
This turned out to be a lot more than I thought it would be. |
How do I test with a simulator? Is it just a matter of adding “REQUIRES: ios” to the test file or is there a special flag I need to pass to the build script? |
Ah, check out docs/Testing.md and the sample |
Sorry for the delay. So basically, we have a bunch of Additionally, the |
I think we don't have a special swifterror convention on 32-bit platforms either. Something like that. @swift-ci Please test |
Oh! Seems like the macOS test just disappeared! Anyway, if it fails then we either need add “REQUIRES: CPU=x86_64” and just not run this on 32-bit or add a “CHECK-LABEL” for each architecture ( |
Hrm. @swift-ci Please test macOS |
Build failed |
I suggest cutting down the CHECK-LABEL line to just match the full name of the function. That should be sufficiently unique, and it's not likely that the parameters are being emitted wrong.
|
Yeah, I've done that now! |
@swift-ci Please test macOS |
@swift-ci Please smoke test Linux |
Build failed |
Tests have passed! Can I cherry-pick this to 5.1? |
This is a pretty contained change, and it only enables more code than before. Yes, I think that's okay! |
Previously, we would emit an error diagnostic if a throwing
@objc
function returnedUnmanaged<T>
. This is now allowed whenT
is representable in Objective-C.For example:
Resolves SR-9035.