From 79d807be82c319b11079aa21e389948ec727e437 Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Sat, 14 Dec 2024 15:08:09 +0100 Subject: [PATCH] Suggestions --- .../errorprone/bugpatterns/ClassCastLambdaUsage.java | 6 +++--- .../errorprone/bugpatterns/ClassCastLambdaUsageTest.java | 9 +++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/ClassCastLambdaUsage.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/ClassCastLambdaUsage.java index 816f87ed654..c50ecfa3b8c 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/ClassCastLambdaUsage.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/ClassCastLambdaUsage.java @@ -54,9 +54,9 @@ public Description matchLambdaExpression(LambdaExpressionTree tree, VisitorState || type.isPrimitive() || type.getKind() == TypeKind.TYPEVAR) { /* - * The method reference syntax does not support casting to parameterized types. Additionally, - * `Class#cast` does not support the same range of type conversions between (boxed) primitive - * types as the cast operator. + * The method reference syntax does not support casting to parameterized types, and type + * variables aren't supported either. Additionally, `Class#cast` does not support the same + * range of type conversions between (boxed) primitive types as the cast operator. */ // XXX: Depending on the declared type of the value being cast, in some cases we _can_ rewrite // primitive casts. Add support for this. diff --git a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/ClassCastLambdaUsageTest.java b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/ClassCastLambdaUsageTest.java index 2f2d0649d3c..e0023951369 100644 --- a/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/ClassCastLambdaUsageTest.java +++ b/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/ClassCastLambdaUsageTest.java @@ -16,7 +16,7 @@ void identification() { "import java.util.stream.Stream;", "", "class A {", - " void m() {", + " void m() {", " Number localVariable = 0;", "", " Stream.of(0).map(i -> i);", @@ -36,13 +36,10 @@ void identification() { " Stream.of(ImmutableSet.of(7)).map(s -> (ImmutableSet) s);", " Stream.of(8).reduce((a, b) -> (Integer) a);", " IntStream.of(9).mapToObj(i -> (char) i);", + " Stream.of(10).map(i -> (T) i);", "", " // BUG: Diagnostic contains:", - " Stream.of(10).map(i -> (Integer) i);", - " }", - "", - " private void m2() {", - " Stream.of(11).map(i -> (T) i);", + " Stream.of(11).map(i -> (Integer) i);", " }", "}") .doTest();