diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/ExplicitArgumentEnumeration.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/ExplicitArgumentEnumeration.java index fbc0c7a097..965e8d8af2 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/ExplicitArgumentEnumeration.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/ExplicitArgumentEnumeration.java @@ -27,6 +27,7 @@ import com.google.errorprone.util.ASTHelpers; import com.sun.source.tree.ExpressionTree; import com.sun.source.tree.MethodInvocationTree; +import com.sun.tools.javac.code.Symbol; import com.sun.tools.javac.code.Symbol.MethodSymbol; import com.sun.tools.javac.code.Symbol.VarSymbol; import java.util.Arrays; @@ -34,6 +35,7 @@ import java.util.Map; import java.util.Optional; import java.util.Set; +import javax.lang.model.element.Modifier; import tech.picnic.errorprone.bugpatterns.util.SourceCode; /** @@ -132,7 +134,7 @@ private static Optional trySuggestCallingVarargsOverload( ImmutableList overloads = ASTHelpers.matchingMethods( method.getSimpleName(), - m -> m.isPublic() && !m.equals(method), + m -> isPublic(m) && !m.equals(method), method.enclClass().type, state.getTypes()) .collect(toImmutableList()); @@ -190,4 +192,9 @@ private static Optional trySuggestCallingCustomAlternative( .merge(fix) .build()); } + + // XXX: Once we target JDK 14+, drop this method in favour of `Symbol#isPublic()`. + private static boolean isPublic(Symbol symbol) { + return symbol.getModifiers().contains(Modifier.PUBLIC); + } }