Skip to content

Consider setter of effectively private var #23211

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

som-snytt
Copy link
Contributor

Anonymous classes get a setter for a var member:
as usual, don't warn about the setter but only about the var getter.

Additionally, check whether the setter is referenced before claiming that the var is unset.

Fixes #23200

Anonymous classes get a setter for a var member:
as usual, don't warn about the setter but only about
the var getter. Additionally, check whether the setter
is referenced before claiming that the var is unset.
@som-snytt som-snytt force-pushed the issue/23200-var-anon branch from 2d4d9e7 to 9f56492 Compare May 20, 2025 23:56
@som-snytt som-snytt marked this pull request as ready for review May 21, 2025 01:21
@som-snytt
Copy link
Contributor Author

isEffectivelyPrivate is Private butNot ParamAccessor, which is convenient for testing whether to checkPrivate (as for some reason we prefer to warn as param) but confusing in checkUnassigned where we must test plain Private explicitly.

For class parameter that is a val/var member, it should "check all that apply" and report whichever is selected by settings. Intuitively (?), people like unused imports (which probably is least relevant to correctness, unless implicits are failing) but unused params, privates, locals have a smaller "sweet spot" where they are just right; yet it's easier to assume -Wunused:all for DX.

@Gedochao Gedochao requested a review from tgodzik May 21, 2025 05:12
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.

-Wunused:all reports setter instead of unset variable in anon class
2 participants