close
The Wayback Machine - https://web.archive.org/web/20201125155112/https://github.com/apple/swift/pull/27382
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

[CSApply] Don't diagnose a 'static let none' as ambiguous none unless its an enum type #27382

Merged
merged 7 commits into from Sep 28, 2019

Conversation

@theblixguy
Copy link
Collaborator

@theblixguy theblixguy commented Sep 26, 2019

We were incorrectly diagnosing the following:

enum Foo {
  case bar
  static let none = 1
}

let optionalFoo: Foo? = .none // warning: assuming you mean 'Optional<Foo>.none'; 
                              // did you mean 'Foo.none' instead?

There's no ambiguity here because .none could only refer to Optional.none, since the type of Foo.none is Int.

We should still offer a warning in case the user does something like this:

enum Foo {
  case bar
  static let none = Foo.bar
}

let optionalFoo: Foo? = .none // warning

Resolves SR-11522.

@theblixguy theblixguy requested review from xedin and jrose-apple Sep 26, 2019
lib/Sema/CSApply.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@brentdax brentdax left a comment

Good idea!

test/decl/enum/enumtest.swift Show resolved Hide resolved
test/decl/enum/enumtest.swift Outdated Show resolved Hide resolved
lib/Sema/CSApply.cpp Outdated Show resolved Hide resolved
@theblixguy theblixguy force-pushed the theblixguy:fix/SR-11522 branch to 389232a Sep 27, 2019
@theblixguy
Copy link
Collaborator Author

@theblixguy theblixguy commented Sep 27, 2019

Alright, this should be good to go now.

@swift-ci please smoke test

lib/Sema/CSApply.cpp Outdated Show resolved Hide resolved
…such as typealiases, structs, etc) by default
@theblixguy theblixguy force-pushed the theblixguy:fix/SR-11522 branch 3 times, most recently Sep 27, 2019
@theblixguy theblixguy force-pushed the theblixguy:fix/SR-11522 branch to b3d7962 Sep 27, 2019
lib/Sema/CSApply.cpp Show resolved Hide resolved
test/decl/enum/enumtest.swift Show resolved Hide resolved
@theblixguy
Copy link
Collaborator Author

@theblixguy theblixguy commented Sep 27, 2019

@swift-ci please smoke test

@theblixguy
Copy link
Collaborator Author

@theblixguy theblixguy commented Sep 28, 2019

@swift-ci please smoke test Linux platform

@theblixguy theblixguy merged commit ad4d623 into apple:master Sep 28, 2019
2 checks passed
2 checks passed
Swift Test Linux Platform (smoke test)
Details
Swift Test OS X Platform (smoke test)
Details
@theblixguy theblixguy deleted the theblixguy:fix/SR-11522 branch Sep 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.