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-11042] Incorrect cast fix-it when type does not conform to a protocol #53431
Comments
I mean, it's possible there's a retroactive conformance…but yeah. |
Maybe we can remove the fix-it to be safe (or make it a conditional cast instead)? or use the `isRetroactive()` check in ProtocolConformance.cpp? |
I mean it's possible there's a conformance in a module that hasn't been imported (usually a downstream module, I'd imagine). A conditional cast is a bad idea because either the types won't match up or it will silently do the wrong thing if the type really doesn't conform. Run-time crashes are good when they represent programmer error. …but not over compile-time errors, so yeah, we could just omit the fix-it when it's casting a concrete type to a protocol. Doesn't prevent someone from writing it explicitly. @xedin, what do you think? |
Sounds good! Although I can't figure out where the fix-it is coming from, because there's nothing in ` MissingContextualConformanceFailure::diagnoseAsError()` (which is emitting the diagnostic) that is emitting the fix-it. It must be coming from somewhere else... |
Also, it doesn't show up in command line (but does in Playgrounds). @xedin do you know where this fix-it is coming from? |
@theblixguy My best guess is that this is Playgrounds with an old compiler (I can reproduce it with 5.1 toolchain) but it doesn't reproduce on master. It is probably one of the diagnostics which has been ported on master but didn't make it to 5.1 branch. |
Oh that’s great! Would be nice to cherry pick it to 5.1 if possible. I’ll close this ticket now. |
Unfortunately that's already too late for it to get into 5.1 |
Environment
Swift 5.1, Xcode 11 beta 2
Additional Detail from JIRA
md5: 712350f192dab89c0863b1de05963282
relates to:
Issue Description:
Example:
The fix-it is incorrect and will cause a runtime crash.
The text was updated successfully, but these errors were encountered: