Skip to content

[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

Merged
merged 18 commits into from
Aug 14, 2019

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Aug 1, 2019

Ignore contextual type mismatch to allow solver to make progress
towards solution and diagnose the problem later.

@xedin
Copy link
Contributor Author

xedin commented Aug 1, 2019

/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.

@xedin xedin force-pushed the diag-conversion-to-specified-type branch 3 times, most recently from cd36d9f to 74e3647 Compare August 7, 2019 06:55
@xedin xedin force-pushed the diag-conversion-to-specified-type branch from 74e3647 to 7c11684 Compare August 13, 2019 07:46
xedin added 16 commits August 13, 2019 11:55
Ignore contextual type mismatch to allow solver to make progress
towards solution and diagnose the problem later.
…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.
@xedin xedin force-pushed the diag-conversion-to-specified-type branch from 7c11684 to d1186f2 Compare August 13, 2019 19:57
xedin added 2 commits August 13, 2019 14:33
…ith `nil`)

Remove the rest of the obsolete code from `diagnoseContextualConversionError`
and port diagnostic about string indexing to new diagnostic framework.
@xedin xedin force-pushed the diag-conversion-to-specified-type branch from d1186f2 to 129092e Compare August 14, 2019 01:33
@xedin xedin marked this pull request as ready for review August 14, 2019 01:34
@xedin
Copy link
Contributor Author

xedin commented Aug 14, 2019

@swift-ci please test

@xedin xedin requested review from DougGregor and hborla August 14, 2019 01:34
@xedin
Copy link
Contributor Author

xedin commented Aug 14, 2019

Besides 2 diagnostic regressions related to protocol composition I consider this done.

@xedin
Copy link
Contributor Author

xedin commented Aug 14, 2019

I'll address them in the follow-up PR since this one is getting pretty big.

@swiftlang swiftlang deleted a comment from swift-ci Aug 14, 2019
@swiftlang swiftlang deleted a comment from swift-ci Aug 14, 2019
Copy link
Member

@DougGregor DougGregor left a 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.

@xedin xedin merged commit 746cad5 into swiftlang:master Aug 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants