[java] The highest language level is now 22

Some tests are adjusted, as now (after unnamed variables release), we warn on every unused lambda parameter

GitOrigin-RevId: 17ce095a19332d22ba0cbcef1e6751ea309ca774
This commit is contained in:
Tagir Valeev
2024-03-15 14:05:44 +00:00
committed by intellij-monorepo-bot
parent 22f3891aa5
commit d4b107d27a
12 changed files with 18 additions and 13 deletions
@@ -19,8 +19,8 @@ public class Test<A, B extends Number> {
public static void main(String[] args) {
Inner<Number, Double> inn = new Inner<>();
inn.<error descr="Ambiguous method call: both 'Inner.m8(IO<? extends Number>)' and 'Inner.m8(IN<? extends Double>)' match">m8</error>(p -> 1.0);
new Test<Number, Integer>().<error descr="Ambiguous method call: both 'Test.foo(IO<? extends Number>)' and 'Test.foo(IN<? extends Integer>)' match">foo</error>(p -> 1.0);
inn.<error descr="Ambiguous method call: both 'Inner.m8(IO<? extends Number>)' and 'Inner.m8(IN<? extends Double>)' match">m8</error>(<warning descr="Parameter 'p' is never used">p</warning> -> 1.0);
new Test<Number, Integer>().<error descr="Ambiguous method call: both 'Test.foo(IO<? extends Number>)' and 'Test.foo(IN<? extends Integer>)' match">foo</error>(<warning descr="Parameter 'p' is never used">p</warning> -> 1.0);
}
}
@@ -1,7 +1,7 @@
class IntStream {
private void foo(IntStream s) {
s.<error descr="Ambiguous method call: both 'IntStream.map(IntUnaryOperator)' and 'IntStream.map(ObjIntFunction<Object>)' match">map</error>(i -> <error descr="Operator '<<' cannot be applied to 'int', '<lambda parameter>'">1 << i</error>);
s.<error descr="Ambiguous method call: both 'IntStream.map(IntUnaryOperator)' and 'IntStream.map(ObjIntFunction<Object>)' match">map</error>(i -> 1);
s.<error descr="Ambiguous method call: both 'IntStream.map(IntUnaryOperator)' and 'IntStream.map(ObjIntFunction<Object>)' match">map</error>(<warning descr="Parameter 'i' is never used">i</warning> -> 1);
s.<error descr="Ambiguous method call: both 'IntStream.map(IntUnaryOperator)' and 'IntStream.map(ObjIntFunction<Object>)' match">map</error>(i -> i);
}
@@ -11,6 +11,6 @@ class Resource<<warning descr="Type parameter 'K' is never used">K</warning>> {
static {
final Optional<String> empty = Optional.empty();
Resource.of(empty.flatMap(s -> empty));
Resource.of(empty.flatMap(<warning descr="Parameter 's' is never used">s</warning> -> empty));
}
}
@@ -14,7 +14,7 @@ interface P<<warning descr="Type parameter 'T' is never used">T</warning>> {
class Test {
void foo(P p) {
p.subscribe(s -> {});
p.subscribe(<warning descr="Parameter 's' is never used">s</warning> -> {});
}
}
@@ -4,7 +4,7 @@ import java.util.function.Function;
class Test {
{
transform(1, (String l) -> null);
transform(1, (String <warning descr="Parameter 'l' is never used">l</warning>) -> null);
}
public static <I, O> void transform(int input, Function<I, O> function) {
@@ -12,6 +12,6 @@ abstract class PertinentToApplicabilityOfExplicitlyTypedLambdaTest {
abstract void foo(B b);
{
<error descr="Ambiguous method call: both 'PertinentToApplicabilityOfExplicitlyTypedLambdaTest.foo(A)' and 'PertinentToApplicabilityOfExplicitlyTypedLambdaTest.foo(B)' match">foo</error>(x -> y -> 42);
<error descr="Ambiguous method call: both 'PertinentToApplicabilityOfExplicitlyTypedLambdaTest.foo(A)' and 'PertinentToApplicabilityOfExplicitlyTypedLambdaTest.foo(B)' match">foo</error>(<warning descr="Parameter 'x' is never used">x</warning> -> <warning descr="Parameter 'y' is never used">y</warning> -> 42);
}
}
@@ -4,7 +4,7 @@ import java.util.function.Predicate;
class Main {
{
new LinkedList<Object>().forEach((value)->{
new LinkedList<Object>().forEach((<warning descr="Parameter 'value' is never used">value</warning>)->{
new LinkedList<Object>().stream().filter((c)->{
return c == null;
});
@@ -15,9 +15,9 @@ abstract class Test {
return x += 1;
});
<error descr="Ambiguous method call: both 'Test.foo(A)' and 'Test.foo(B)' match">foo</error>(x -> <error descr="Incompatible types. Found: 'int', required: '<lambda parameter>'">x += 1</error>);
foo(x -> 1);
foo(<warning descr="Parameter 'x' is never used">x</warning> -> 1);
foo(x -> <error descr="Operator '!' cannot be applied to 'int'">!x</error>);
<error descr="Ambiguous method call: both 'Test.foo(A)' and 'Test.foo(B)' match">foo</error>(x -> <error descr="Operator '++' cannot be applied to '<lambda parameter>'">++x</error>);
foo(x -> o instanceof String ? 1 : 0);
foo(<warning descr="Parameter 'x' is never used">x</warning> -> o instanceof String ? 1 : 0);
}
}