calc types by applicability constraints if inference fails

include all inference variables for resolve and ignore additional constraints checks if the inference is going to failure; this way if (expr()) would get type of the 'standalone' expression instead of expression with boolean as expected type
This commit is contained in:
Anna.Kozlova
2017-12-07 15:51:06 +01:00
parent c9a3fba58c
commit 1fc76eb779
17 changed files with 69 additions and 66 deletions
@@ -5,7 +5,7 @@ import java.util.function.Consumer;
class Test {
public static void main(String[] args) {
Iterable<Consumer<Reader>> i = Arrays.asList(<error descr="Unhandled exception: IOException">(r) -> r.read()</error>);
Iterable<Consumer<Reader>> i = Arrays.asList((r) -> r.<error descr="Unhandled exception: java.io.IOException">read()</error>);
Iterable<Consumer<Reader>> i1 = Arrays.<Consumer<Reader>>asList((r) -> r.<error descr="Unhandled exception: java.io.IOException">read()</error>);
}
}
@@ -10,10 +10,7 @@ class Test {
<R> SuperFoo<R> foo(I<R> ax) { return null; }
SuperFoo<String> ls = foo(<error descr="Incompatible types. Required SuperFoo<String> but 'foo' was inferred to SuperFoo<R>:
no instance(s) of type variable(s) exist so that String conforms to Number
inference variable R has incompatible bounds:
equality constraints: String
upper bounds: Object, Number">() -> new Foo<>()</error>);
no instance(s) of type variable(s) exist so that String conforms to Number">() -> new Foo<>()</error>);
SuperFoo<Integer> li = foo(() -> new Foo<>());
SuperFoo<?> lw = foo(() -> new Foo<>());
}
@@ -26,10 +26,7 @@ abstract class NoFormalParamTypeInferenceNeeded {
{
map(a -> zip(text -> text));
zip(a -> zip(text -> text));
Integer zip = zip(<error descr="no instance(s) of type variable(s) exist so that Object conforms to Integer
inference variable R has incompatible bounds:
lower bounds: Object
upper bounds: Object, Integer">a -> zip(text -> text)</error>);
Integer zip = zip(<error descr="no instance(s) of type variable(s) exist so that Object conforms to Integer">a -> zip(text -> text)</error>);
}
}
@@ -7,7 +7,7 @@ class Test {
<T extends Runnable> void call1(T t) {}
{
call(<error descr="Object is not a functional interface">() -> {}</error>);
call(<error descr="Target type of a lambda conversion must be an interface">() -> {}</error>);
call1(() -> {});
}
}