Skip to content

SE-0036 (2/3): Provide warnings when referencing enum elements on instances #2842

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 1 commit into from
Jul 10, 2016

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Jun 2, 2016

What's in this pull request?

This is part 2/3 implementing SE-0036:

This provides warnings when referencing an enum element on an instance together with a single-dot fix-it for case statements and a fully qualified name fix-it everywhere else.

Dependencies

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 builds on top of them, i.e. the branch for this PR is one commit ahead of the one for #2841. I hope that’s the right way to go, otherwise let me know.

Note to those familiar with the old error-based implementation in #2634

The detection in the warning-bases approach is completely different to the one used when errors were generated. As a result, I wasn’t able to provide the same fix-its. Especially I can no longer determine that a single dot suffices if the type could be inferred based on the constraint system's contextType, e.g. in self = .A. As you can see in the updated tests in #2841, almost all migration help seems to be about migrating case statements, however. So I believe that it’s not that big a deal if in these cases a fully qualified type is suggested.


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.

@slavapestov
Copy link
Contributor

Hi Alex,

Sorry for not looking at this sooner. Do you mind resolving the conflicts and rebasing onto the latest master branch?

@ahoppen ahoppen force-pushed the SR-1236-warnings branch from a0cd2b6 to ae1058a Compare July 9, 2016 09:12
@ahoppen
Copy link
Member Author

ahoppen commented Jul 9, 2016

No, worries. Merge conflicts are now resolved

void add(ValueDecl *found, ValueDecl *base, Type foundInType) {
///
/// \param promotedInstanceRef true if the lookup result to be added was
/// actually looked up on an instance but promted to a type to look up an
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo - "promted"

I would just name this "fixItAddLeadingDot" or something really explicit.

@slavapestov
Copy link
Contributor

@swift-ci Please test

@slavapestov
Copy link
Contributor

If you don't want to rename the parameter, that's fine, since I understand it's going away soon anyway.

@slavapestov
Copy link
Contributor

I'm going to merge this -- I'll let you decide if you want to rename the fields or not.

@slavapestov slavapestov merged commit 0a12750 into swiftlang:master Jul 10, 2016
@ahoppen
Copy link
Member Author

ahoppen commented Jul 11, 2016

Thanks. I'll just let it be as it is. As you said, the code is about to disappear soon anyway.

@ahoppen ahoppen deleted the SR-1236-warnings branch July 11, 2016 05: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