java error message: explicit method reference ambiguity (IDEA-250654)

GitOrigin-RevId: 1fc5f577f298a7f874a111866a394aa7a6c09cc0
This commit is contained in:
Anna Kozlova
2020-09-14 19:04:15 +02:00
committed by intellij-monorepo-bot
parent aff9c8468a
commit 34526b2b5c
15 changed files with 40 additions and 37 deletions

View File

@@ -25,8 +25,8 @@ class AlienTest {
static {
IInt i1 = MyTest::<error descr="Cannot resolve method 'abracadabra'">abracadabra</error>;
IInt i2 = MyTest::<error descr="Incompatible types: int is not convertible to String">foo</error>;
IInt i3 = MyTest::<error descr="Cannot resolve method 'bar'">bar</error>;
IIntInt i4 = MyTest::<error descr="Cannot resolve method 'bar'">bar</error>;
IInt i3 = MyTest::<error descr="Reference to 'bar' is ambiguous, both 'bar(Integer, Number)' and 'bar(Number, Integer)' match">bar</error>;
IIntInt i4 = MyTest::<error descr="Reference to 'bar' is ambiguous, both 'bar(Integer, Number)' and 'bar(Number, Integer)' match">bar</error>;
IInt i5 = <error descr="Non-static method cannot be referenced from a static context">MyTest::baz</error>;
IInt i6 = <error descr="'foo(int)' is not public in 'MyTest.Foo'. Cannot be accessed from outside package">MyTest.foo::foo</error>;
IInt i7 = MyTest.<error descr="'MyTest.Foo' has private access in 'MyTest'">Foo</error>::foo;

View File

@@ -22,7 +22,7 @@ class MyTest {
{
Bar1 b1 = MyTest :: foo;
bar(MyTest :: <error descr="Cannot resolve method 'foo'">foo</error>);
bar(MyTest :: <error descr="Reference to 'foo' is ambiguous, both 'foo(int)' and 'foo(String)' match">foo</error>);
}
}
@@ -122,7 +122,7 @@ class MyTest4 {
}
{
bar(MyTest4:: <error descr="Cannot resolve method 'foo'">foo</error>);
bar(MyTest4:: <error descr="Reference to 'foo' is ambiguous, both 'foo(int)' and 'foo(String)' match">foo</error>);
}
}

View File

@@ -16,7 +16,7 @@ class Test {
class Test1 {
{
Runnable b = Test1 :: <error descr="Cannot resolve method 'length'">length</error>;
Runnable b = Test1 :: <error descr="Reference to 'length' is ambiguous, both 'length(String)' and 'length(Integer)' match">length</error>;
Comparable<String> c = Test1 :: length;
Comparable<Integer> c1 = Test1 :: length;
}

View File

@@ -6,7 +6,7 @@ interface Func<TIn, TOut>{
class Main {
public static void main(final String[] args) {
Func<Integer, String> func = Integer::<error descr="Cannot resolve method 'toString'">toString</error>;
Func<Integer, String> func = Integer::<error descr="Reference to 'toString' is ambiguous, both 'toString(int)' and 'toString()' match">toString</error>;
System.out.println(func.run(6));
}
}

View File

@@ -2,7 +2,7 @@ import java.util.*;
class LambdaTest {
public void testR() {
new ArrayList<String>() :: <error descr="Cannot resolve method 'size'">size</error> = "";
new ArrayList<String>() :: <error descr="Reference to 'size' is ambiguous, both 'size()' and 'size()' match">size</error> = "";
}
}

View File

@@ -57,10 +57,10 @@ class MyTest1 {
I2 s2 = MyTest1 :: m2;
call2(MyTest1::m2);
I2 s3 = MyTest1 :: <error descr="Cannot resolve method 'm3'">m3</error>;
call2(MyTest1::<error descr="Cannot resolve method 'm3'">m3</error>);
I2 s4 = MyTest1 ::<error descr="Cannot resolve method 'm4'">m4</error>;
call2(MyTest1::<error descr="Cannot resolve method 'm4'">m4</error>);
I2 s3 = MyTest1 :: <error descr="Reference to 'm3' is ambiguous, both 'm3(MyTest1, String)' and 'm3(String)' match">m3</error>;
call2(MyTest1::<error descr="Reference to 'm3' is ambiguous, both 'm3(MyTest1, String)' and 'm3(String)' match">m3</error>);
I2 s4 = MyTest1 ::<error descr="Reference to 'm4' is ambiguous, both 'm4(MyTest1, String)' and 'm4(String)' match">m4</error>;
call2(MyTest1::<error descr="Reference to 'm4' is ambiguous, both 'm4(MyTest1, String)' and 'm4(String)' match">m4</error>);
}
}
@@ -106,19 +106,19 @@ class MyTest2 {
I2 s2 = MyTest2 :: m2;
call2(MyTest2::m2);
I2 s3 = MyTest2 :: <error descr="Cannot resolve method 'm3'">m3</error>;
call2(MyTest2::<error descr="Cannot resolve method 'm3'">m3</error>);
I2 s4 = MyTest2 ::<error descr="Cannot resolve method 'm4'">m4</error>;
call2(MyTest2::<error descr="Cannot resolve method 'm4'">m4</error>);
I2 s3 = MyTest2 :: <error descr="Reference to 'm3' is ambiguous, both 'm3(MyTest2, String)' and 'm3(String)' match">m3</error>;
call2(MyTest2::<error descr="Reference to 'm3' is ambiguous, both 'm3(MyTest2, String)' and 'm3(String)' match">m3</error>);
I2 s4 = MyTest2 ::<error descr="Reference to 'm4' is ambiguous, both 'm4(MyTest2, String)' and 'm4(String)' match">m4</error>;
call2(MyTest2::<error descr="Reference to 'm4' is ambiguous, both 'm4(MyTest2, String)' and 'm4(String)' match">m4</error>);
}
static void call3(I1 s) {}
static void call3(I2 s) {}
static {
call3(MyTest2::m1);
call3(MyTest2::<error descr="Cannot resolve method 'm2'">m2</error>);
call3(MyTest2::<error descr="Reference to 'm2' is ambiguous, both 'm2(MyTest2, String)' and 'm2(String)' match">m2</error>);
call3(MyTest2::m3);
call3(MyTest2::<error descr="Cannot resolve method 'm4'">m4</error>);
call3(MyTest2::<error descr="Reference to 'm4' is ambiguous, both 'm4(MyTest2, String)' and 'm4(String)' match">m4</error>);
}
}

View File

@@ -50,7 +50,7 @@ class MyTest {
I1 i1 = MyTest::static_1;
I1 i2 = MyTest::<error descr="Cannot resolve method 'static_2'">static_2</error>;
I1 i3 = MyTest::<error descr="Incompatible types: int is not convertible to String">static_3</error>;
I1 i4 = MyTest::<error descr="Cannot resolve method 'static_4'">static_4</error>;
I1 i4 = MyTest::<error descr="Reference to 'static_4' is ambiguous, both 'static_4(String...)' and 'static_4(String...)' match">static_4</error>;
}
@@ -58,12 +58,12 @@ class MyTest {
I1 i_1 = <error descr="Non-static method cannot be referenced from a static context">MyTest::_1</error>;
I1 i_2 = <error descr="Non-static method cannot be referenced from a static context">MyTest::_2</error>;
I1 i_3 = <error descr="Non-static method cannot be referenced from a static context">MyTest::_3</error>;
I1 i_4 = MyTest::<error descr="Cannot resolve method '_4'">_4</error>;
I1 i_4 = MyTest::<error descr="Reference to '_4' is ambiguous, both '_4(String...)' and '_4(String...)' match">_4</error>;
I1 i1 = this::_1;
I1 i2 = this::<error descr="Cannot resolve method '_2'">_2</error>;
I1 i3 = this::<error descr="Incompatible types: int is not convertible to String">_3</error>;
I1 i4 = this::<error descr="Cannot resolve method '_4'">_4</error>;
I1 i4 = this::<error descr="Reference to '_4' is ambiguous, both '_4(String...)' and '_4(String...)' match">_4</error>;
I2 i21 = MyTest::<error descr="Cannot resolve method 'm1'">m1</error>;
I2 i22 = MyTest::<error descr="Cannot resolve method 'm2'">m2</error>;

View File

@@ -16,7 +16,7 @@ class DemoApplicationTests {
Stream.of("")
.map(l -> a.get(l.length()))
.map(s -> new DemoApplicationTests()).findAny()
.map(d -> d.foo(this::<error descr="Cannot resolve method 'bar'">ba<caret>r</error>));
.map(d -> d.foo(this::<error descr="Reference to 'bar' is ambiguous, both 'bar(long)' and 'bar(int)' match">bar</error>));
}
<T> void foo(Consumer<T> c) {}

View File

@@ -31,8 +31,8 @@ class Test {
String i1 = instanceCall(this::m0);
String i2 = instanceCall(this::m1);
String i3 = instanceCall(this::m2);
String i4 = instanceCall(this::<error descr="Cannot resolve method 'm01'">m01</error>);
String i5 = instanceCall(this::<error descr="Cannot resolve method 'm012'">m012</error>);
String i4 = instanceCall(this::<error descr="Reference to 'm01' is ambiguous, both 'm01()' and 'm01(String)' match">m01</error>);
String i5 = instanceCall(this::<error descr="Reference to 'm012' is ambiguous, both 'm012()' and 'm012(String)' match">m012</error>);
}
void n0() { }
@@ -53,7 +53,7 @@ class Test {
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 s4 = staticCall(Test::<error descr="Cannot resolve method 'n01'">n01</error>);
Test s5 = staticCall(Test::<error descr="Cannot resolve method 'n012'">n012</error>);
Test s4 = staticCall(Test::<error descr="Reference to 'n01' is ambiguous, both 'n01()' and 'n01(String)' match">n01</error>);
Test s5 = staticCall(Test::<error descr="Reference to 'n012' is ambiguous, both 'n012()' and 'n012(String)' match">n012</error>);
}
}

View File

@@ -34,7 +34,7 @@ class Test {
{
Set<String> m = replyWith(this::query);
System.out.println(m);
Set<String> m1 = replyWith(this::<error descr="Cannot resolve method 'query1'">query1</error>);
Set<String> m1 = replyWith(this::<error descr="Reference to 'query1' is ambiguous, both 'query1()' and 'query1(String)' match">query1</error>);
System.out.println(m1);
}
}

View File

@@ -10,6 +10,6 @@ class Test {
static void m(Test t, Object s) {}
static void test() {
I i = Test::<error descr="Cannot resolve method 'm'">m</error>;
I i = Test::<error descr="Reference to 'm' is ambiguous, both 'm(Test, String)' and 'm(String)' match">m</error>;
}
}

View File

@@ -7,7 +7,7 @@ class Main {
Function<A<String>, String> f1 = A<String>::getName;
Function<A<String>, String> f10 = A::getName;
Function<B, String> f2 = B::getName;
Function<B, String> f3 = b::<error descr="Cannot resolve method 'getName'">getName</error>;
Function<B, String> f3 = b::<error descr="Reference to 'getName' is ambiguous, both 'getName()' and 'getName(I)' match">getName</error>;
}
}