Skip to content

SE-0036: Requiring Leading Dot Prefixes for Enum Instance Member Implementations (once again) #2634

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

Closed
wants to merge 3 commits into from

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented May 21, 2016

What's in this pull request?

This is a follow up to #2224, which has been merged and reversed, implementing SE-0036: Requiring Leading Dot Prefixes for Enum Instance Member Implementations

I added the following fix-its to the original PR:

  • Fix-it using . where the type can be inferred using the constraint system’s contextual type, e.g. self = A to self = .A
  • Fix-it using . in case statements of non-generic enum elements
  • Fix-it using the fully specified type without generic parameters everywhere else. Generic parameters could be inferred in all examples I could think of.

The generation of the fix-it for case statements is, for my taste, quite ugly as it directly references the ~= pattern matching operator and its arguments. But it was the best solution I could think of without rerunning the constraint system on a modified copy of the AST, where a . has been added as a guess.

Thus, I would suggest removing the fix-it once the transition to Swift 3 has been finished, for example in the Swift 4 timeframe. I guess it provides little benefit apart from automated transitioning anyway.

Resolved bug number: (SR-1236)


Before merging this pull request to apple/swift repository:

  • Test pull request on Swift continuous integration.

Triggering Swift CI

The swift-ci is triggered by writing a comment on this PR addressed to the GitHub user @swift-ci. Different tests will run depending on the specific comment that you use. The currently available comments are:

Smoke Testing

Platform Comment
All supported platforms @swift-ci Please smoke test
OS X platform @swift-ci Please smoke test OS X platform
Linux platform @swift-ci Please smoke test Linux platform

Validation Testing

Platform Comment
All supported platforms @swift-ci Please test
OS X platform @swift-ci Please test OS X platform
Linux platform @swift-ci Please test Linux platform

Note: Only members of the Apple organization can trigger swift-ci.

@DougGregor
Copy link
Member

The implementation is looking good, but I'd like us to stage things a bit more softly via warnings + Fix-Its, and we'll wait until some time later before making this a hard error. First of all, all of the test suite changes that merely change to the always-permitted-but-now-required qualified syntax can just go in, so you won't need to carry that change set around. Second, instead of changing name lookup and breaking existing programs, I propose that we detect when an unqualified reference is referring to an enum case, produce a warning with Fix-Its (which you have great logic for), but allow the code to compile. That will help developers move forward with this change without unnecessary breakage.

@ahoppen
Copy link
Member Author

ahoppen commented Jun 2, 2016

I created three PRs, each referencing a further state in the deployment of SE-0036:

@ahoppen ahoppen closed this Jun 2, 2016
@ahoppen ahoppen deleted the SR-1236 branch July 9, 2016 11:13
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