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 Jan 21, 2024
1 parent 15cf6da commit d3877c5
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),

Check warning on line 137 in error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/ExplicitArgumentEnumeration.java

View workflow job for this annotation

GitHub Actions / pitest

3 different changes can be made to a lambda on line 137 without causing a test to fail

removed conditional - replaced equality check with true in 1st lambda in trySuggestCallingVarargsOverload (covered by 2 tests RemoveConditionalMutator_EQUAL_IF) removed conditional - replaced equality check with true in 1st lambda in trySuggestCallingVarargsOverload (covered by 2 tests RemoveConditionalMutator_EQUAL_IF) replaced boolean return with true for 1st lambda in trySuggestCallingVarargsOverload (covered by 2 tests BooleanTrueReturnValsMutator)
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);

Check warning on line 198 in error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/ExplicitArgumentEnumeration.java

View workflow job for this annotation

GitHub Actions / pitest

A change can be made to line 198 without causing a test to fail

replaced boolean return with true for isPublic (covered by 2 tests BooleanTrueReturnValsMutator)
}
}

0 comments on commit d3877c5

Please sign in to comment.