-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[ConstraintSystem] Further unwrap cleanup #18699
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
@swift-ci Please smoke test |
…(previously just allowed for Subtypes). This allows us to always find MissingOptionalUnwrapFailures, so that all the unwrap fixit code can be moved into CSDiagnostics and made static.
…AttemptFixes is off.
@swift-ci Please smoke test |
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.
As I mentioned in previous PR, this make sense to me! Could you try recording a fix right away? It seems like that should work, and duplicate fix should be ignored (when attempted) later on because it would have the same locator?
I investigated this further, and the issue is slightly different than I originally thought, and I don't think there's any good way to construct the needed fix(es) in advance. The test that addresses this is SR-1069 which is in tests/Constraints/closures.swift. Even further simplified, the issue arises here:
Interestingly, without this PR the current code handles the above fine, but breaks down with a mix of multiple arguments:
... whereas after this PR, we get the much better suggestion of unwrap fixits for arguments |
@swift-ci Please smoke test. |
Sounds good to me! |
@swift-ci Please smoke test |
This was part of PR #18324
If
shouldAttemptFixes()
then when we are trying to bind type variables, ifT?
fails, then attempt to bindT
for all binding types. This was already happening and valid for subtype bindings. This change tries it for supertype and identity bindings because it allows us the opportunity tomatchTypes()
aT?
value to aT
bound variable by diagnosing a missing unwrap.This was the only situation in which we were previously missing finding that Fix in the constraint system, so with this change all of the unwrap diagnosis can be moved into the new CSDiagnostics.cpp and made static.