new inference: report inference errors of containing call for lambdas

This commit is contained in:
Anna Kozlova
2015-11-20 21:41:40 +01:00
parent 19a7ef3488
commit be2db1f940
9 changed files with 28 additions and 25 deletions

View File

@@ -21,7 +21,7 @@ class NoInferenceResult {
m((String s1) -> s1.length());
m((String s1) -> s1);
m1<error descr="'m1(T)' in 'NoInferenceResult' cannot be applied to '(<lambda expression>)'">(() -> { })</error>;
m1(<error descr="Object is not a functional interface">() -> { }</error>);
Foo<String> foo = new Foo<String>();
foo.map(v -> null);

View File

@@ -12,7 +12,9 @@ class TypeArgsConsistency {
I<Integer> i1 = (i, j) -> i + j;
foo((i, j) -> i + j);
I<Integer> i2 = bar((i, j) -> i + j);
I<Integer> i3 = bar((i, j) -> <error descr="Bad return type in lambda expression: String cannot be converted to Integer">"" + i + j</error>);
I<Integer> i3 = bar(<error descr="inference variable X has incompatible bounds:
equality constraints: Integer
lower bounds: String">(i, j) -> "" + i + j</error>);
}
}
@@ -30,7 +32,7 @@ class TypeArgsConsistency1 {
I<Integer> i1 = (i, j) -> i + j;
foo((i, j) -> i + j);
I<Integer> i2 =bar((i, j) -> i) ;
I<Integer> i3 = bar((i, j) -> <error descr="Bad return type in lambda expression: String cannot be converted to int">"" + i + j</error>);
I<Integer> i3 = bar(<error descr="Bad return type in lambda expression: String cannot be converted to int">(i, j) -> "" + i + j</error>);
}
}
@@ -43,7 +45,9 @@ class TypeArgsConsistency2 {
I<Integer> i1 = bar(x -> x);
I1<Integer> i2 = bar1(x -> 1);
I2<String> aI2 = bar2(x -> "");
I2<Integer> aI28 = bar2( x-> <error descr="Bad return type in lambda expression: String cannot be converted to Integer">""</error>);
I2<Integer> aI28 = bar2( <error descr="inference variable T has incompatible bounds:
equality constraints: Integer
lower bounds: String">x-> ""</error>);
I2<Integer> i3 = bar2(x -> x);
I2<Integer> i4 = bar2(x -> foooI());
System.out.println(i4.foo(2));