Skip to content

[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

Merged
merged 3 commits into from
Sep 3, 2021

Conversation

jackgmarch
Copy link
Contributor

@jackgmarch jackgmarch commented Jun 20, 2021

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

@jackgmarch jackgmarch marked this pull request as draft June 20, 2021 18:43
@jackgmarch jackgmarch changed the title Sr 4559 [SR-4559] Warn when unapplied reference to a function 'self' is referenced in property initialiser. Jun 20, 2021
@jackgmarch jackgmarch changed the title [SR-4559] Warn when unapplied reference to a function 'self' is referenced in property initialiser. [SR-4559] Warn when unapplied reference to a function 'self' is referenced in property initialiser Jun 20, 2021
@jackgmarch jackgmarch force-pushed the SR-4559 branch 3 times, most recently from 2322a37 to 6175a3f Compare August 20, 2021 19:50
@jackgmarch jackgmarch marked this pull request as ready for review August 20, 2021 20:17
@jackgmarch jackgmarch marked this pull request as draft August 20, 2021 20:18
@jackgmarch jackgmarch marked this pull request as ready for review August 20, 2021 20:34
@jackgmarch jackgmarch force-pushed the SR-4559 branch 3 times, most recently from 367d811 to b681f1d Compare August 20, 2021 23:47
@varungandhi-apple
Copy link
Contributor

@swift-ci smoke test

@jackgmarch jackgmarch requested a review from xedin August 29, 2021 11:41
Copy link
Contributor

@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.

Makes sense to me, I left a single question inline.

@varungandhi-apple
Copy link
Contributor

@swift-ci smoke test

@jackgmarch
Copy link
Contributor Author

@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

@xedin
Copy link
Contributor

xedin commented Sep 3, 2021

@swift-ci please smoke test

@xedin xedin merged commit b721488 into swiftlang:main Sep 3, 2021
@xedin
Copy link
Contributor

xedin commented Sep 3, 2021

Thank you, @jackgmarch!

keith added a commit to keith/swift that referenced this pull request Feb 23, 2022
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
keith added a commit that referenced this pull request 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 https://bugs.swift.org/browse/SR-15691
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-4559] Method called 'self' can be confused with regular 'self'
3 participants