Skip to content

Keep unused annot on params #23037

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

Fixes #23033

This commit just ensures unused annotation is retained for parameters. The previous tweak excluded constructor params (probably out of fear).

My limited understanding is that the meta annots decide what to do for fields: which elements receive the annotation.

For a class param, I assumed you don't know whether a param incurs a field until constructors. Does a using param always incur a field?

For the fix, follow the example of publicInBinary to retain the annotation.

A justification is that if I ask not to warn, I always mean don't warn about any of the things, so extra unused annotations is benign.

Should unused have the param meta annot? It is redundant because if there is a field, you will always use the param through a paramaccessor, which is either the field itself or the getter, and both will be annotated unused.

@som-snytt
Copy link
Contributor Author

ok I'll run the whole test suite locally after switching to jdk 17 because it's impossible to tell from CI failures whether it is my fault.

@som-snytt som-snytt force-pushed the issue/23033-unused-class-param branch from 58e7acd to 8c37715 Compare April 24, 2025 12:31
@som-snytt som-snytt marked this pull request as ready for review April 24, 2025 14:43
@Gedochao Gedochao requested a review from KacperFKorban April 25, 2025 06:46
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.

unused annotation does not silence warning in given using with shorthand
2 participants