-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Sema][NFC] Correcting test case for SR-11535 and adding an explanation comment #34744
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
[Sema][NFC] Correcting test case for SR-11535 and adding an explanation comment #34744
Conversation
@swift-ci Please smoke test |
Do you think we should try to offer a warning here (“assuming you mean |
Not really sure, I think the warning only makes sense if we have ambiguity and the one was favored(because the other one is a valid option too). Also, in this case, fix-it to |
Yeah, I could go either way on this. While there might not be strictly be ambiguity, I think for any readers of the code it’s likely that Also, we could offer a fix-it which uses the same type parameter we’ve actually resolved |
That makes sense, but I wonder if users that intentionally try to do that relying on this since is correct behavior, will not be able to use type inference without a warning. So we will be kinda enforcing to always use explicit type annotation when accessing |
If we do offer a warning here, I think it should only be present when the contextual type of the
The first line should generate a warning, but the second line should be fine. My personal opinion is that diagnostics, in addition to guiding users to write correct code, should also guide them to write readable code. If we can identify cases where there's a potential ambiguity to the reader, we should try to mitigate that. We don't allow the user to silence the warning generated when This is all very subjective, though! I don't feel very strongly either way between warning/no warning. |
That totally makes sense :) I took a shot at implementing the warning, so let's hear from others and see if this may be a good option, otherwise, we can just drop the last commit and move-on just updating the test case. |
5f2dfc3
to
4322ff2
Compare
4322ff2
to
20c2d77
Compare
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.
Instead of discovering this post-factum how about we just convert this into a warning fix and detect the issue in simplifyMemberConstraint
?
Right! I'm on it :) |
f17edb5
to
6896014
Compare
The latest changes are dependent on member lookup changes from #34715 |
6896014
to
abf452b
Compare
@LucianoPAlmeida Sorry for the delay on my PR... I've had less free time than expected over the past couple weeks. If you have any desire to take a crack at writing the requested unit test yourself I would happily accept a pull request into my branch, otherwise I will try to get to it by next week. |
@Jumhyn Don't worry, we can wait for it no problem :) |
e906eb3
to
9fc8463
Compare
@LucianoPAlmeida My PR has been merged so you should be unblocked on this one now :) |
@Jumhyn Awesome! Thanks |
…ved member that could be an unwraped base member
9fc8463
to
d954b84
Compare
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.
LGTM! I have left a couple of minor suggestions inline.
@swift-ci Please smoke test |
@xedin Any other point or is good to go? |
|
Thank you :) |
Correcting the test case already added and adding an explanation comment.
cc @Jumhyn