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 UnusedVariable false positives for private record parameters #4049

Closed
wants to merge 1 commit into from

Conversation

copybara-service[bot]
Copy link
Contributor

Fix UnusedVariable false positives for private record parameters

Fixes #2713

It looks like the tree emitted by the compiler is incomplete for the canonical constructor of a record, which is why the parameters were erroneously flagged as unused. Apparently this only affected private record classes because for them the implicit canonical constructor is private as well, and the UnusedVariable check treats parameters of private methods and constructors differently.

#2713 (comment) showed an example where this also affected record fields, however I was unable to reproduce that. Maybe they were using an older Error Prone version which does not include 47da3af, their sample code is incomplete, or my test setup was incorrect.
Edit: It looks like they were using an older Error Prone version, see #2713 (comment).

Fixes #3837

FUTURE_COPYBARA_INTEGRATE_REVIEW=#3837 from Marcono1234:record-unused-param-false-positives 4535778

Fixes #2713

It looks like the tree emitted by the compiler is incomplete for the canonical constructor of a record, which is why the parameters were erroneously flagged as unused. Apparently this only affected `private` record classes because for them the implicit canonical constructor is `private` as well, and the `UnusedVariable` check treats parameters of `private` methods and constructors differently.

#2713 (comment) showed an example where this also affected record fields, however I was unable to reproduce that. Maybe they were using an older Error Prone version which does not include 47da3af, their sample code is incomplete, or my test setup was incorrect.
Edit: It looks like they were using an older Error Prone version, see #2713 (comment).

Fixes #3837

FUTURE_COPYBARA_INTEGRATE_REVIEW=#3837 from Marcono1234:record-unused-param-false-positives 4535778
PiperOrigin-RevId: 557194050
@copybara-service copybara-service bot closed this Aug 24, 2023
@copybara-service copybara-service bot deleted the test_557194050 branch August 24, 2023 11:28
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.

UnusedVariable sometimes gives false positives for record parameters
1 participant