-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Runtime] Handle Error-conforming-to-NSObject casting fully. #28700
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
[Runtime] Handle Error-conforming-to-NSObject casting fully. #28700
Conversation
@swift-ci please test |
Build failed |
Build failed |
Yikes, I thought #28406 had already been reverted with the rest. And it's still unfixed, thank you. |
D'oh. :( |
I missed a case where an Error-conforming class is dynamically casted to NSObject (via NSError). Fix it.
This prevents runtime differences on as? from affecting this test.
…SObject. Rather than attempting Error bridging early when trying to dynamically cast to NSError or NSObject, treat it as the *last* thing we do when all else fails. Push most of this code over into Objective-C-specific handling rather than #ifdef'd into the main casting logic to make that slightly more clear. One oddity of Error/NSError bridging is that a class that conforms to Error can be dynamically cast to NSObject via Error bridging. This has always been known to the static compiler, but the runtime itself was not always handling such a cast uniformly. Do so now, uniformly. However, this forced us to weaken an assertion, because casting a class type to NSError or NSObject can produce an object with a different identity. Fixes rdar://problem/57393991.
This reverts commit 29a6d10.
8767ec3
to
169dbcd
Compare
@swift-ci please test |
1 similar comment
@swift-ci please test |
@swift-ci please test macOS |
1 similar comment
@swift-ci please test macOS |
@swift-ci please test platform macOS |
Build failed |
@swift-ci please test platform macOS |
Build failed |
@swift-ci please test Linux |
I'm going to merge because other PRs will be built on top of this, but we'll back it out of there are any concerns. |
Looks good! |
Rather than attempting Error bridging early when trying to dynamically
cast to NSError or NSObject, treat it as the last thing we do when
all else fails. Push most of this code over into Objective-C-specific
handling rather than #ifdef'd into the main casting logic to make that
slightly more clear.
One oddity of Error/NSError bridging is that a class that conforms to
Error can be dynamically cast to NSObject via Error bridging. This has
always been known to the static compiler, but the runtime itself was
not always handling such a cast uniformly. Do so now,
uniformly. However, this forced us to weaken an assertion, because
casting a class type to NSError or NSObject can produce an object with
a different identity.
Fixes rdar://problem/57393991.