-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SR-4559] Warn when unapplied reference to a function 'self' is referenced in property initialiser #37992
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
Conversation
2322a37
to
6175a3f
Compare
367d811
to
b681f1d
Compare
@swift-ci smoke test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me, I left a single question inline.
…to method named "self" can be used without qualification) https://bugs.swift.org/browse/SR-4559
…n be used without qualification) https://bugs.swift.org/browse/SR-4559
@swift-ci smoke test |
@varungandhi-apple I'm assuming cause I pushed after you did the smoke test the smoke tests haven't run, guessing you need to start them again? thanks for starting them initially |
@swift-ci please smoke test |
Thank you, @jackgmarch! |
swiftlang#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
#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
#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)
A fix to warn when unapplied references to a function called 'self' from are referenced unqualified from property initialisers.
Update: have fixed false positive referred to in strikethrough:
I'm having an issue though where my error message still shows when the reference is not unapplied. This is not allowed as it uses an instance method from a non-lazy initialiser, so there is no need for the error message I've added. Not sure how best to fix this as I'm brand new to Swift compiler contributions so any ideas would be much appreciated, I've already added a check for unapplied reference before showing the diagnostic. I'm assuming it technically is still treated as an unapplied reference because you can't call the function from a property initialiser, even though I have included the brackets to call it.Resolves #47136