mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
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:
+1
-4
@@ -7,10 +7,7 @@ class Test {
|
||||
final Class<? extends ClassB> bClass = null;
|
||||
ClassB b = factory.create(bClass);
|
||||
String str = <error descr="Incompatible types. Required String but 'create' was inferred to T:
|
||||
no instance(s) of type variable(s) exist so that capture of ? extends ClassB conforms to String
|
||||
inference variable T has incompatible bounds:
|
||||
equality constraints: capture of ? extends ClassB
|
||||
upper bounds: ClassA<I>, Object, String">factory.create(bClass);</error>
|
||||
no instance(s) of type variable(s) exist so that capture of ? extends ClassB conforms to String">factory.create(bClass);</error>
|
||||
}
|
||||
|
||||
public static class Factory {
|
||||
|
||||
+3
-3
@@ -15,13 +15,13 @@ class NoInferenceResult {
|
||||
<T> void m1(T t) { }
|
||||
|
||||
void test() {
|
||||
m(<error descr="Object is not a functional interface">(String s1) -> (String s2) -> s1 + s2</error>);
|
||||
m(<error descr="Object is not a functional interface">(String s1) -> {return (String s2) -> s1 + s2;}</error>);
|
||||
m((String s1) -> <error descr="Target type of a lambda conversion must be an interface">(String s2) -> s1 + s2</error>);
|
||||
m((String s1) -> {return <error descr="Target type of a lambda conversion must be an interface">(String s2) -> s1 + s2</error>;});
|
||||
|
||||
m((String s1) -> s1.length());
|
||||
m((String s1) -> s1);
|
||||
|
||||
m1(<error descr="Object is not a functional interface">() -> { }</error>);
|
||||
m1(<error descr="Target type of a lambda conversion must be an interface">() -> { }</error>);
|
||||
|
||||
Foo<String> foo = new Foo<String>();
|
||||
foo.map(v -> null);
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ class NoLambda {
|
||||
static <T> T id(T i2) {return i2;}
|
||||
|
||||
{
|
||||
id(<error descr="Object is not a functional interface">() -> {System.out.println("hi");}</error>);
|
||||
id(<error descr="Target type of a lambda conversion must be an interface">() -> {System.out.println("hi");}</error>);
|
||||
NoLambda.<Runnable>id(() -> {System.out.println("hi");});
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -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>);
|
||||
}
|
||||
}
|
||||
+1
-4
@@ -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<>());
|
||||
}
|
||||
+1
-4
@@ -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>);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -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(() -> {});
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
class Test {
|
||||
{
|
||||
asList(<error descr="Integer is not a functional interface">o -> {}</error>, 1, 2, 3);
|
||||
asList(<error descr="T is not a functional interface">Test::foo</error>, 1, 2, 3);
|
||||
asList(<error descr="Target type of a lambda conversion must be an interface">o -> {}</error>, 1, 2, 3);
|
||||
asList(<error descr="Integer is not a functional interface">Test::foo</error>, 1, 2, 3);
|
||||
}
|
||||
|
||||
void foo() {}
|
||||
|
||||
Reference in New Issue
Block a user