Skip to content

Commit

Permalink
Exclude primitives in ClassCastLambdaUsage check
Browse files Browse the repository at this point in the history
  • Loading branch information
mohamedsamehsalah committed Oct 30, 2024
1 parent 9940576 commit 438a0b3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public Description matchLambdaExpression(LambdaExpressionTree tree, VisitorState
}

Type type = ASTHelpers.getType(typeCast);
if (type == null || type.isParameterized()) {
if (type == null || type.isParameterized() || type.isPrimitive()) {

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

View workflow job for this annotation

GitHub Actions / pitest

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

removed conditional - replaced equality check with true (covered by 2 tests RemoveConditionalMutator_EQUAL_IF)
return Description.NO_MATCH;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ void identification() {
.addSourceLines(
"A.java",
"import com.google.common.collect.ImmutableSet;",
"import java.util.stream.IntStream;",
"import java.util.stream.Stream;",
"",
"class A {",
Expand All @@ -34,6 +35,7 @@ void identification() {
" Stream.<ImmutableSet>of(ImmutableSet.of(5)).map(l -> (ImmutableSet<Number>) l);",
" Stream.of(ImmutableSet.of(6)).map(l -> (ImmutableSet<?>) l);",
" Stream.of(7).reduce((a, b) -> (Integer) a);",
" IntStream.of(8).mapToObj(a -> (char) a);",
"",
" // BUG: Diagnostic contains:",
" Stream.of(8).map(i -> (Integer) i);",
Expand Down

0 comments on commit 438a0b3

Please sign in to comment.