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
[SR-10337] Swift 5 regression: Incorrect type cast from AnyObject to incompatible NSObject subclass. #52737
Comments
Comment by Ian Leitch (JIRA) Actually this doesn't appear to be unique to just NSManagedObject, it's an issue for any NSObject subclass. |
Comment by Ian Leitch (JIRA) AnyObject appears to be the culprit, the snippet works as expected when using just Any. |
Reproduced on 5.1 as well: 2019-04-08 16:22:52.727 swift[75171:9957983] *** NSForwarding: warning: object 0x7fc281d4e2a0 of class 'whats_wrong.MyModel' does not implement methodSignatureForSelector: -- trouble ahead
Unrecognized selector -[whats_wrong.MyModel objectID] |
cc @mikeash |
Most curious! Thank you for the small reproducer. |
Comment by Ian Leitch (JIRA) This is also an issue when running 4.2 compatibility mode. |
Yeah, that's a compilation-time setting. You're still running with a Swift 5.0 runtime and standard library in that case. |
Comment by Ian Leitch (JIRA) @belkadan Thanks for pointing that out, I didn't realize it was a compile-time only setting. |
Environment
Xcode 10.2 (10E125)
Apple Swift version 5.0 (swiftlang-1001.0.69.5 clang-1001.0.46.3)
Target: x86_64-apple-darwin18.5.0
Additional Detail from JIRA
md5: 115bba5912ffd2e281835116b906c630
Issue Description:
The following code crashes in Xcode 10.2 as the model is incorrectly cast to an NSManagedObject instance:
This is not a problem in Xcode 10.1.
The text was updated successfully, but these errors were encountered: