Skip to content

[Diagnostics] Handle CoerceExpr conversion failure in contextual mismatch #29011

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

Conversation

LucianoPAlmeida
Copy link
Contributor

While working in #27895, more specifically in 82529a6 I note that the cannot convert diagnostic for expr Double(1) as Double as String is being emitted via fix but still going re-typechecking passing through CSDiag. Note that actually when tried to put a if (Options.contains(ConstraintSystemFlags::SubExpressionDiagnostics)) in applySolutionFixes.
So this PR is to handle coercion conversion error early on repairFailures and avoid this.
This also handles the TODO diagnostic in test/type/subclass_composition.swift.

cc @xedin @hborla :))

@xedin xedin self-requested a review January 5, 2020 06:54
@xedin
Copy link
Contributor

xedin commented Jan 5, 2020

@LucianoPAlmeida Thank you, I'll take a look on Monday! Meanwhile, can check you check how much fails if you remove FailureDiagnosis::visitCoerceExpr?

@LucianoPAlmeida
Copy link
Contributor Author

Sure @xedin, will check as soon as possible 👍

@LucianoPAlmeida
Copy link
Contributor Author

LucianoPAlmeida commented Jan 5, 2020

@xedin removing FailureDiagnosis::visitCoerceExpr only fails 5 tests:

Failing Tests (5):
    Swift(macosx-x86_64) :: Generics/conditional_conformances_literals.swift
    Swift(macosx-x86_64) :: Sema/suppress-argument-labels-in-types.swift
    Swift(macosx-x86_64) :: expr/cast/metatype_casts.swift
    Swift(macosx-x86_64) :: expr/cast/optional.swift
    Swift(macosx-x86_64) :: type/subclass_composition_objc.swift

  Expected Passes    : 4950
  Expected Failures  : 23
  Unsupported Tests  : 122
  Unexpected Failures: 5

I do remove some obsolete code from it, but can try to figure out the missing cases in a follow-up PR so it can be removed for good \o/
Most of them are coercions involving metatypes, so probably handle a complex locator should fix most ... other cases I have to look and see why they are failing :)

@xedin
Copy link
Contributor

xedin commented Jan 6, 2020

@LucianoPAlmeida That would be great!

Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! I have left a minor naming suggesting inline.

@xedin
Copy link
Contributor

xedin commented Jan 6, 2020

@swift-ci please smoke test

@xedin xedin merged commit 36fff23 into swiftlang:master Jan 6, 2020
@LucianoPAlmeida
Copy link
Contributor Author

@xedin Thanks, I'm starting to work on handle the other failures, maybe we'll have something soon :)

@LucianoPAlmeida LucianoPAlmeida deleted the coercion-handle-contextual-mismatch branch January 7, 2020 03:20
@xedin
Copy link
Contributor

xedin commented Jan 7, 2020

Sounds good, thank you!

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.

2 participants