mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 18:50:54 +07:00
new overload resolution: first check that collected methods are potentially compatible with args; for generic methods without specified type arguments this already means that they are applicable; for non generic methods (or raw method calls) expressions should be compatible with parameter types (formal parameter types = actual types as substitutor is known) (IDEA-147798)
This commit is contained in:
@@ -66,9 +66,9 @@ class Test2 {
|
||||
{
|
||||
bar(x -> x);
|
||||
bar1(x -> x);
|
||||
bar2(1, x -> <error descr="Bad return type in lambda expression: List<Integer> cannot be converted to Integer">x</error>);
|
||||
bar2("", x -> <error descr="Bad return type in lambda expression: List<String> cannot be converted to String">x</error>);
|
||||
bar3(x -> <error descr="Bad return type in lambda expression: List<String> cannot be converted to String">x</error>, "");
|
||||
bar2(1, <error descr="Bad return type in lambda expression: List<Integer> cannot be converted to Integer">x -> x</error>);
|
||||
bar2("", <error descr="Bad return type in lambda expression: List<String> cannot be converted to String">x -> x</error>);
|
||||
bar3(<error descr="Bad return type in lambda expression: List<String> cannot be converted to String">x -> x</error>, "");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import java.util.Optional;
|
||||
|
||||
class Resource<<warning descr="Type parameter 'K' is never used">K</warning>> {
|
||||
private static <T> Resource<T> <warning descr="Private method 'of(T)' is never used">of</warning>(T <warning descr="Parameter 'data' is never used">data</warning>) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static <T> Resource<T> of(Optional<T> <warning descr="Parameter 'i' is never used">i</warning>) {
|
||||
return null;
|
||||
}
|
||||
|
||||
static {
|
||||
final Optional<String> empty = Optional.empty();
|
||||
Resource.of(empty.flatMap(s -> empty));
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ class Test {
|
||||
}
|
||||
|
||||
void bar(C c) {
|
||||
foo(c, x -> <error descr="Bad return type in lambda expression: A cannot be converted to C">x.f()</error>);
|
||||
foo(c, <error descr="Bad return type in lambda expression: A cannot be converted to C">x -> x.f()</error>);
|
||||
foo(c, x -> x);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ class Test {
|
||||
static {
|
||||
Test s1 = staticCall(Test::n0);
|
||||
Test s2 = staticCall(Test::n1);
|
||||
Test s3 = staticCall<error descr="Cannot resolve method 'staticCall(<method reference>)'">(Test::n2)</error>;
|
||||
Test s3 = <error descr="Cannot resolve method 'staticCall(<method reference>)'">staticCall</error>(Test::n2);
|
||||
Test s4 = staticCall<error descr="Ambiguous method call: both 'Test.staticCall(I1<Test>)' and 'Test.staticCall(I2<Test, String>)' match">(Test::n01)</error>;
|
||||
Test s5 = staticCall<error descr="Ambiguous method call: both 'Test.staticCall(I1<Test>)' and 'Test.staticCall(I2<Test, String>)' match">(Test::n012)</error>;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class Foo {
|
||||
System.out.println(s);
|
||||
});
|
||||
|
||||
<error descr="Cannot resolve method 'foo(<lambda expression>)'">foo</error>((String p, String k) -> {
|
||||
foo(<error descr="Incompatible parameter types in lambda expression: expected int but found String">(String p, String k)</error> -> {
|
||||
System.out.println(p);
|
||||
});
|
||||
}
|
||||
@@ -62,7 +62,7 @@ class WithTypeParams {
|
||||
System.out.println(p);
|
||||
});
|
||||
|
||||
<error descr="Cannot resolve method 'foo(<lambda expression>)'">foo</error>((int k) -> {System.out.println(k);});
|
||||
foo(<error descr="Incompatible parameter types in lambda expression: expected String but found int">(int k)</error> -> {System.out.println(k);});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user