Skip to content
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

[SR-15281] [Sema] Couple of contextual mismatch and runtime cast diagnostic fixes #39648

Merged
merged 4 commits into from Oct 10, 2021

Conversation

LucianoPAlmeida
Copy link
Collaborator

This is twofold:
First commit is taking into account value-to-optional restrictions for an extra layer of optionality when recording the fix,
because otherwise we would compute the same type conversion.

  var b1: B {
    a.flatMap(B.init(a:)) as! B 
   // flatMap opens a type variable for generic parameter as result `T?` with a layer of optionality that we were not 
   // considering so fix was considering only `B` as! `B` which lead to misleading diagnostic reported.
  }

Second commit: Instead of suggesting a ' as! B' fix-it on B? to B contextual mismatch, if we know from type has a subtype relation with to type, it would make more sense to suggest a force unwrap "!".

Resolves SR-15281.

@LucianoPAlmeida
Copy link
Collaborator Author

@swift-ci Please smoke test

@LucianoPAlmeida
Copy link
Collaborator Author

@swift-ci Please smoke test MacOS Platform

Copy link
Member

@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 good! Left a couple of minor comments inline.

lib/Sema/CSDiagnostics.cpp Outdated Show resolved Hide resolved
lib/Sema/CSSimplify.cpp Outdated Show resolved Hide resolved
lib/Sema/CSSimplify.cpp Outdated Show resolved Hide resolved
@LucianoPAlmeida
Copy link
Collaborator Author

@swift-ci Please smoke test

@LucianoPAlmeida
Copy link
Collaborator Author

@swift-ci Please test Windows Platform

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.

None yet

2 participants