-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SR-13899] [Sema] Adjustments on coerce to checked cast diagnostics #34883
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-13899] [Sema] Adjustments on coerce to checked cast diagnostics #34883
Conversation
@swift-ci Please smoke test |
Thanks for the holiday gift, you are our secret 🎅 |
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.
Looks good but it would be great if we could detect that conditional cast could be used during solving, would it be possible? That way we could use a special fix/diagnostic for it instead of adding that for "forced" downcast which is kind of misleading...
Humm, do you think is worth another fix/diagnostic for that? Maybe we could make the "forced" downcast more generic and if we detect that conditional cast could be used when solving pass as an additional parameter to the fix and diagnostics. WDYT? |
@xedin Let me know what you think of this approach :) |
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.
Looks much better! I have left a nit comment about naming of the failure, feel free to merge once that's fixed.
…he CoerceToCheckedCast fix
85ac0a1
to
ac65e6f
Compare
@swift-ci Please smoke test |
Thanks @xedin! |
Based on https://forums.swift.org/t/missing-conditional-cast-fix-it/42282
This proposes to adjust coerce to checked cast diagnostic to be broken into the diagnostic and fix-it note.
Also, cases were the coercion result has a value to optional restriction e.g. conditional binding
we suggest conditional downcast
as?
instead of force downcast.The break into a note is more like a proposal not really the SR, so let me know what you think :)
cc @dan-zheng
Resolves SR-13899.