inference errors: make applicability error thread safe so multiple threads can perform overload resolution of parent method calls independently, save presentable error when substitutor cached only

This commit is contained in:
Anna Kozlova
2017-05-08 12:12:13 +03:00
parent fa07225451
commit 77f4894aae
36 changed files with 145 additions and 136 deletions
@@ -5,7 +5,7 @@ class A {
public static void main(String[] args) {
B<? extends CharSequence> q = new B<>();
Func x = q::<error descr="Invalid method reference: CharSequence cannot be converted to capture of ? extends CharSequence">foo</error>;
Func x = q::<error descr="Cannot resolve method 'foo'">foo</error>;
x.invoke("");
}
@@ -7,7 +7,7 @@ interface B<BT> {
class Test {
public static void test() {
method1(Test::<error descr="Invalid method reference: A<capture of ? super M> cannot be converted to A<? super String>">method2</error>);
method1(Test::<error descr="Cannot resolve method 'method2'">method2</error>);
}
static <M> void method1(B<A<? super M>> arg) { }
@@ -4,7 +4,7 @@ import java.util.function.Predicate;
class MyTest {
{
BiConsumer<Predicate<? extends Runnable>, Predicate<? extends Runnable>> or = MyTest::<error descr="Invalid method reference: Predicate<capture of ? extends Runnable> cannot be converted to Predicate<E>">or</error>;
BiConsumer<Predicate<? extends Runnable>, Predicate<? extends Runnable>> or = MyTest::<error descr="Cannot resolve method 'or'">or</error>;
}
private static <E extends Runnable> void or(Predicate<E> left, Predicate<E> right) {}
@@ -29,14 +29,14 @@ class Test {
static void meth4(I3 s) { }
static {
meth1(Foo::<error descr="Invalid constructor reference: String cannot be converted to Number">new</error>);
meth1(Foo::<error descr="Cannot resolve constructor 'Foo'">new</error>);
meth2(Foo::new);
meth3(Foo::<error descr="Invalid constructor reference: Object cannot be converted to Number">new</error>);
meth3(Foo::<error descr="Cannot resolve constructor 'Foo'">new</error>);
meth4<error descr="Ambiguous method call: both 'Test.meth4(I1)' and 'Test.meth4(I2)' match">(Foo::new)</error>;
meth1(Test::<error descr="Invalid method reference: String cannot be converted to X">foo</error>);
meth1(Test::<error descr="Cannot resolve method 'foo'">foo</error>);
meth2(Test::foo);
meth3(Test::<error descr="Invalid method reference: Object cannot be converted to X">foo</error>);
meth3(Test::<error descr="Cannot resolve method 'foo'">foo</error>);
meth4<error descr="Ambiguous method call: both 'Test.meth4(I1)' and 'Test.meth4(I2)' match">(Test::foo)</error>;
}
@@ -55,8 +55,8 @@ class Test {
}
void test() {
II1 i1 = this::<error descr="Invalid method reference: X cannot be converted to X">fooInstance</error>;
II1 i1 = this::<error descr="Cannot resolve method 'fooInstance'">fooInstance</error>;
II2 i2 = this::fooInstance;
II3 i3 = this::<error descr="Invalid method reference: X cannot be converted to X">fooInstance</error>;
II3 i3 = this::<error descr="Cannot resolve method 'fooInstance'">fooInstance</error>;
}
}
@@ -17,7 +17,7 @@ abstract class Test {
{
I i = Test::<String>foo;
I i1 = Test::<Integer><error descr="Invalid method reference: String cannot be converted to Integer">foo</error>;
I i1 = Test::<Integer><error descr="Cannot resolve method 'foo'">foo</error>;
I i2 = Test::foo;
}
@@ -4,7 +4,7 @@ class InlineRef {
<K> void foo(Consumer<K> f) {}
void bar(){
foo(Descriptor::<error descr="Invalid method reference: Object cannot be converted to Descriptor">getName</error>);
foo(Descriptor::<error descr="Cannot resolve method 'getName'">getName</error>);
}
}
@@ -4,6 +4,6 @@ import java.util.Comparator;
class Main {
public void test() {
Collections.sort(new ArrayList<error descr="Cannot infer arguments"><></error>(), <error descr="Non-static method cannot be referenced from a static context">Comparator::reversed</error>);
Collections.sort(new ArrayList<>(), <error descr="Non-static method cannot be referenced from a static context">Comparator::reversed</error>);
}
}