-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Typechecker] Fix fix-it location for missing try when called on optional protocol value #26606
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 @xedin |
Would it be possible to instead store a |
I think that could work. I believe at the moment we're passing the
This is what the AST looks like. The same
If the |
@theblixguy Yeah, currently If |
… on a protocol typed value" This reverts commit 60d52f0.
…aqueValueExpr in openExistentialReference()
Sounds good. This works for my test case. @xedin Does the change look good to you? I haven't changed it so it stores the entire |
ping @xedin did you had a chance to take a look at this? Thanks! |
Thanks for the reminder! This is in my queue, I'll try to take a look ASAP. |
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 great!
@swift-ci please smoke test |
When we call a throwing method on an optional protocol-typed value and forget to add
try
/try?
/try!
, then we emit the fix-it at the wrong location. This is because the source locations forOptionalEvaluationExpr
points to the throwing method rather than the outer value. We also have some additional expressions, such as anOpenExistentialExpr
, which wraps theCallExpr
of the throwing method and holds the correct source location for the fix-it.Example:
Resolves SR-11016.