Skip to content

SE-0036 (3/3): Provide errors when referencing enum elements on instances #2843

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 2 commits into from
Jul 21, 2016

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Jun 2, 2016

What's in this pull request?

This is part 3/3 implementing SE-0036.

It undos the changes done in #2842 that provided warnings when an enum element was referenced on an enum and implements a different logic that throws errors instead.

It has slightly better fix-its than the warning-based approach because it can also detect if a single dot suffices as a fix-it in expressions where the type can be inferred on the context, e.g. in self = .A. However, it looses the ability to infer a single-dot fix-it in case statements for generic enums.

The resulting code is basically the same as in #2634.

Dependencies

Same text as in #2842:
I wasn’t sure how I should handle the multi-staged rollout of SE-0036 as described here. So this PR includes the changes to the test cases that shall be merged in #2841 and #2842 and builds on top of them, i.e. the branch for this PR is two commits ahead of the one for #2842. I hope that’s the right way to go, otherwise let me know.

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
All supported platforms @swift-ci Please smoke test and merge
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
All supported platforms @swift-ci Please test and merge
OS X platform @swift-ci Please test OS X platform
OS X platform @swift-ci Please benchmark
Linux platform @swift-ci Please test Linux platform

Lint Testing

Language Comment
Python @swift-ci Please Python lint

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

@@ -139,6 +139,8 @@ Swift 3.0
`NS[Mutable]Dictionary` are still imported as nongeneric classes for
the time being.

* [SE-0036](https://github.com/apple/swift-evolution/blob/master/proposals/0036-enum-dot.md):
Enum elements can no longer be accessed like instance members in instance methods.
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a newline after for consistency

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@slavapestov
Copy link
Contributor

@DougGregor or @lattner can you take a look at this patch?

@ahoppen
Copy link
Member Author

ahoppen commented Jul 19, 2016

I guess this will still need to be merged for Swift 3

@DougGregor
Copy link
Member

@swift-ci please smoke test and merge

ahoppen added 2 commits July 20, 2016 16:25
…members

This removes the logic which issued warnings when accessing enum
elements as instance members (SE-0036), making room for a new
implementation that will issue errors instead.

This reverts commit ae1058a.
@ahoppen
Copy link
Member Author

ahoppen commented Jul 20, 2016

Reverting the changes for the warnings fixed a crash.
The other failure was fixed in 2c10bec.

@swift-ci please test and merge

@DougGregor
Copy link
Member

The LLDB failures are real... it looks like there are a few test cases that need to be updated there. @ahoppen, can you create a PR against LLDB to fix up those errors? We'll merge that one first.

@ahoppen
Copy link
Member Author

ahoppen commented Jul 21, 2016

LLDB pull request is created apple/swift-lldb#35

@DougGregor
Copy link
Member

@swift-ci please smoke test and merge

@DougGregor
Copy link
Member

LLDB PR merged, so I kicked off another round of smoke-test-and-merge

@swift-ci swift-ci merged commit a766e6f into swiftlang:master Jul 21, 2016
@ahoppen ahoppen deleted the SR-1236-errors branch June 26, 2017 17:36
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.

4 participants