-
Notifications
You must be signed in to change notification settings - Fork 744
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
False UnusedVariable warning for method parameters only used in overridden implementations #4409
Comments
#4409 PiperOrigin-RevId: 637010056
#4409 PiperOrigin-RevId: 637894916
(Is this fixed by #4433, which started off being about a regression test but seems to have developed into an actual fix?) |
Can confirm that the issue is fixed in 2.29.0. Thank you for solving it so quickly! |
A false positive UnusedVariable issue was fixed in 2.29.0 See google/error-prone#4409
As of 2.29.1, the warning still happens when the descendant is an anonymous class: |
Consider the following example:
Expected result: no warnings
Actual result: ErrorProne complains about
usedInDescendants
parameter ofApp.Base.doStuff
being unused. However, this parameter is used by the overridden method inDescendant
class and cannot be easily removed.There are several workarounds, but they aren't universally applicable:
Even converting the
Base
to an interface with default method still triggers the warning.A full reproducer can be found at
https://github.com/mlopatkin/errorprone-issue-reproducers/tree/trunk/unused-variable-overloaded-method
Tested with ErrorProne 2.27.1, 2.24.1 on Java 11 and Java 21.
The text was updated successfully, but these errors were encountered: