inference: do not check return type during inference; separate highlighting check

This commit is contained in:
anna
2013-10-08 17:00:09 +02:00
parent 9e060c7ebb
commit 69dbc89461
6 changed files with 57 additions and 17 deletions

View File

@@ -64,12 +64,12 @@ class MyTest1 {
}
void foo(Object[] arr) {
<error descr="Incompatible types. Found: '<method reference>', required: 'MyTest1.I1'">I1 c1 = arr :: clone;</error>
I1 c1 = <error descr="Bad return type in method reference: cannot convert java.lang.Object[] to int[]">arr :: clone</error>;
I2 c2 = arr :: clone;
<error descr="Incompatible types. Found: '<method reference>', required: 'MyTest1.I3'">I3 c3 = arr::clone;</error>
<error descr="Incompatible types. Found: '<method reference>', required: 'MyTest1.I4'">I4 c5 = arr::clone;</error>
I3 c3 = <error descr="Bad return type in method reference: cannot convert java.lang.Object[] to char[]">arr::clone</error>;
I4 c5 = <error descr="Bad return type in method reference: cannot convert java.lang.Object[] to boolean">arr::clone</error>;
I5 c4 = this::getClass;
<error descr="Incompatible types. Found: '<method reference>', required: 'MyTest1.I6'">I6 c6 = this::getClass;</error>
I6 c6 = <error descr="Bad return type in method reference: cannot convert java.lang.Class<? extends MyTest1> to java.lang.Class<MyTest1>">this::getClass</error>;
}
}

View File

@@ -10,6 +10,6 @@ class GetClassTest {
void test(int[] iarr, List<String> ls) {
GetCl c4 = ls::getClass;
<error descr="Incompatible types. Found: '<method reference>', required: 'GetClassTest.GetClReturnTypeProblems'">GetClReturnTypeProblems c5 = ls::getClass;</error>
GetClReturnTypeProblems c5 = <error descr="Bad return type in method reference: cannot convert java.lang.Class<? extends java.util.List> to java.lang.Class<java.util.List<java.lang.String>>">ls::getClass</error>;
}
}

View File

@@ -45,11 +45,11 @@ class MyTestConstructor {
}
private static void <warning descr="Private method 'foo(MyTestConstructor.I1)' is never used">foo</warning>(I1 i) {System.out.println(i);}
private static void foo(I2 i) {System.out.println(i);}
private static void <warning descr="Private method 'foo(MyTestConstructor.I2)' is never used">foo</warning>(I2 i) {System.out.println(i);}
private static void <warning descr="Private method 'foo(MyTestConstructor.I3)' is never used">foo</warning>(I3 i) {System.out.println(i);}
static {
foo(Foo::new);
foo<error descr="Ambiguous method call: both 'MyTestConstructor.foo(I1)' and 'MyTestConstructor.foo(I2)' match">(Foo::new)</error>;
}
}
@@ -74,10 +74,10 @@ class MyTestMethod {
static <X extends Number> Foo<X> m() { return null; }
private static void <warning descr="Private method 'foo(MyTestMethod.I1)' is never used">foo</warning>(I1 i) {System.out.println(i);}
private static void foo(I2 i) {System.out.println(i);}
private static void <warning descr="Private method 'foo(MyTestMethod.I2)' is never used">foo</warning>(I2 i) {System.out.println(i);}
private static void <warning descr="Private method 'foo(MyTestMethod.I3)' is never used">foo</warning>(I3 i) {System.out.println(i);}
static {
foo(MyTestMethod::m);
foo<error descr="Ambiguous method call: both 'MyTestMethod.foo(I1)' and 'MyTestMethod.foo(I2)' match">(MyTestMethod::m)</error>;
}
}

View File

@@ -20,7 +20,7 @@ class MyTest {
System.out.println(i);
}
private static void foo(I2 i) {
private static void <warning descr="Private method 'foo(MyTest.I2)' is never used">foo</warning>(I2 i) {
System.out.println(i);
}
@@ -29,7 +29,7 @@ class MyTest {
}
public static void main(String[] args) {
foo(Foo::m);
foo<error descr="Ambiguous method call: both 'MyTest.foo(I1)' and 'MyTest.foo(I2)' match">(Foo::m)</error>;
}
}