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

Fix invalid warning for enum cases named self #41520

Merged

Conversation

keith
Copy link
Collaborator

@keith keith commented Feb 23, 2022

#37992 introduced a warning when you
were likely to confuse self with TypeName.self, this also applied to
enum cases that were named self, these cases should not be easily
confused at call sites since their use requires prefixing them with a
.. There was also no way to avoid this warning since other syntax such
as TypeName.self, which produces the enum type instead, or
TypeName.`self` which produced the same warning again.

Fixes #57970

@keith
Copy link
Collaborator Author

keith commented Feb 23, 2022

cc @xedin @jackgmarch since you all worked on the original

@keith
Copy link
Collaborator Author

keith commented Feb 23, 2022

@swift-ci please test

@xedin xedin self-requested a review February 23, 2022 02:34
Copy link
Member

@xedin xedin left a comment

Choose a reason for hiding this comment

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

Thank you, looks good!

lib/Sema/MiscDiagnostics.cpp Outdated Show resolved Hide resolved
apple#37992 introduced a warning when you
were likely to confuse `self` with `TypeName.self`, this also applied to
enum cases that were named `self`, these cases should not be easily
confused at call sites since their use requires prefixing them with a
`.`. There was also no way to avoid this warning since other syntax such
as `TypeName.self`, which produces the enum type instead, or
`` TypeName`.self` `` which produced the same warning again.

Fixes https://bugs.swift.org/browse/SR-15691
@keith keith force-pushed the ks/fix-invalid-warning-for-enum-cases-named-self branch from 93cfaab to 7ef6486 Compare February 23, 2022 03:13
@keith
Copy link
Collaborator Author

keith commented Feb 23, 2022

@swift-ci please test

@keith keith marked this pull request as ready for review February 23, 2022 17:45
@keith keith merged commit f6b2e2e into apple:main Feb 23, 2022
@keith keith deleted the ks/fix-invalid-warning-for-enum-cases-named-self branch February 23, 2022 17:46
@keith
Copy link
Collaborator Author

keith commented Feb 23, 2022

Hoping to cherry pick this into 5.6 in #41529

DougGregor pushed a commit that referenced this pull request Mar 23, 2022
#37992 introduced a warning when you
were likely to confuse `self` with `TypeName.self`, this also applied to
enum cases that were named `self`, these cases should not be easily
confused at call sites since their use requires prefixing them with a
`.`. There was also no way to avoid this warning since other syntax such
as `TypeName.self`, which produces the enum type instead, or
`` TypeName.`self` `` which produced the same warning again.

Fixes https://bugs.swift.org/browse/SR-15691

(cherry picked from commit f6b2e2e)
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.

[SR-15691] Invalid warning: 'self' refers to the method 'Foo.self'
2 participants