-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[ConstraintSystem] Add a fix to ignore contextual type mismatch #26459
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
[ConstraintSystem] Add a fix to ignore contextual type mismatch #26459
Conversation
/cc @sl This is still work in progress since I have to port some tailored diagnostics over but you can see that there are some decent improvements here already. I think this is final major preliminary work required before porting argument-to-parameter conversion mismatches. |
cd36d9f
to
74e3647
Compare
74e3647
to
7c11684
Compare
Ignore contextual type mismatch to allow solver to make progress towards solution and diagnose the problem later.
…l mismatches to new framework
…ConstraintSystem Functions like `isRawRepresentable*` and `conformsToKnownProtocol` have to be be shared between CSDiag and new diagnostics framework until relevant code is removed from the former.
…ns are attempted This makes sure that solver is able to produce specialized fixes in some cases e.g. existential conversions, mismatched generic arguments, or force unwraps before fallback to generic `cannot convert X to Y` failure.
Behavior changed when it became possible to omit `return` in single expression functions but it hasn't been diagnosed correctly.
Detect that contextual conversion is between a dictionary type and an array type which comes form an array literal and produce a tailored diagnostic.
…ic expressoin If contextual failure is detected in sub-expression (through type-check call via CSDiag), let's make sure that fix-it is always anchored at semantic expression otherwise it could be attached to the paren representing whole argument list.
…ismatch If the only difference between two functions is `throws` and it is not a subtype relationship, let's repair the problem by dropping `throws` attribute and letting solver continue to search for a solution, which would later be diagnosed.
7c11684
to
d1186f2
Compare
…ith `nil`) Remove the rest of the obsolete code from `diagnoseContextualConversionError` and port diagnostic about string indexing to new diagnostic framework.
…protocol composition
d1186f2
to
129092e
Compare
@swift-ci please test |
Besides 2 diagnostic regressions related to protocol composition I consider this done. |
I'll address them in the follow-up PR since this one is getting pretty big. |
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.
This looks great! I love seeing the CSDiag code away in favor of nicely-structured code.
Ignore contextual type mismatch to allow solver to make progress
towards solution and diagnose the problem later.