Skip to content

[5.5][Diagnostics] Handle ambiguities related to use of nil literal #37291

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 3 commits into from
May 7, 2021

Conversation

xedin
Copy link
Contributor

@xedin xedin commented May 6, 2021

  • Explanation:

When nil is passed as an argument to call with multiple overloads
it's possible that this would result in ambiguity where matched
expected argument type doesn't conform to ExpressibleByNilLiteral.

To handle situations like this locator for contextual mismatch
has to be adjusted to point to the call where nil is used, so
diagnoseAmbiguityWithFixes can identify multiple overloads and
produce a correct ambiguity diagnostic.

  • Scope: Invalid expressions where nil is passed to an incompatible parameter

  • Resolves: rdar://75514153

  • Risk: Very low

  • Reviewed By: @hborla

  • Testing: Regression tests added to the suite

Resolves: rdar://75514153

xedin added 3 commits May 6, 2021 11:53
…rgument position

New note mentions both expected argument type and its position
and anchors to the affected overload choice.

(cherry picked from commit af3dcf0)
When `nil` is passed as an argument to call with multiple overloads
it's possible that this would result in ambiguity where matched
expected argument type doesn't conform to `ExpressibleByNilLiteral`.

To handle situations like this locator for contextual mismatch
has to be adjusted to point to the call where `nil` is used, so
`diagnoseAmbiguityWithFixes` can identify multiple overloads and
produce a correct ambiguity diagnostic.

Resolves: rdar://75514153
(cherry picked from commit 29cb7dd)
@xedin xedin added the r5.5 label May 6, 2021
@xedin xedin requested a review from a team as a code owner May 6, 2021 18:57
@xedin
Copy link
Contributor Author

xedin commented May 6, 2021

@swift-ci please test

@airspeedswift
Copy link
Member

Original is #37178

@airspeedswift airspeedswift merged commit 378b1be into swiftlang:release/5.5 May 7, 2021
@AnthonyLatsis AnthonyLatsis added 🍒 release cherry pick Flag: Release branch cherry picks swift 5.5 labels Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 5.5
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants