Skip to content

Commit

Permalink
Fix JDK 11 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan202 committed Feb 11, 2024
1 parent d05305f commit c9cbbcb
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@
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;
import java.util.List;
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;

/**
Expand Down Expand Up @@ -132,7 +134,7 @@ private static Optional<SuggestedFix> trySuggestCallingVarargsOverload(
ImmutableList<MethodSymbol> overloads =
ASTHelpers.matchingMethods(
method.getSimpleName(),
m -> m.isPublic() && !m.equals(method),
m -> isPublic(m) && !m.equals(method),
method.enclClass().type,
state.getTypes())
.collect(toImmutableList());
Expand Down Expand Up @@ -190,4 +192,9 @@ private static Optional<SuggestedFix> 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);
}
}

0 comments on commit c9cbbcb

Please sign in to comment.