Skip to content

Commit affa37a

Browse files
graememorganError Prone Team
authored and
Error Prone Team
committed
Do not flag unused parameters on _abstract_ methods.
I think this was introduced in 88a224c, where we suddenly start considering some _effectively_ private abstract methods. PiperOrigin-RevId: 590895990
1 parent d78dd6d commit affa37a

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

core/src/main/java/com/google/errorprone/bugpatterns/UnusedVariable.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,8 @@ private boolean isParameterSubjectToAnalysis(Symbol sym) {
706706
checkArgument(sym.getKind() == ElementKind.PARAMETER);
707707
Symbol enclosingMethod = sym.owner;
708708

709-
if (!(enclosingMethod instanceof MethodSymbol)) {
709+
if (!(enclosingMethod instanceof MethodSymbol)
710+
|| isAbstract((MethodSymbol) enclosingMethod)) {
710711
return false;
711712
}
712713

core/src/test/java/com/google/errorprone/bugpatterns/UnusedVariableTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,9 @@ public void unusedParamInPrivateMethod() {
263263
" System.out.println(i);",
264264
" }",
265265
" }",
266+
" private interface Foo {",
267+
" void foo(int a);",
268+
" }",
266269
" public void main() {",
267270
" test(1, 2);",
268271
" }",

0 commit comments

Comments
 (0)