mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 11:00:04 +07:00
method references: don't swallow errors during method ref inference (IDEA-179706)
This commit is contained in:
+1
-1
@@ -5,7 +5,7 @@ class A {
|
||||
public static void main(String[] args) {
|
||||
B<? extends CharSequence> q = new B<>();
|
||||
|
||||
Func x = q::<error descr="Cannot resolve method 'foo'">foo</error>;
|
||||
Func x = q::<error descr="Incompatible types: CharSequence is not convertible to capture of ? extends CharSequence">foo</error>;
|
||||
x.invoke("");
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ interface B<BT> {
|
||||
|
||||
class Test {
|
||||
public static void test() {
|
||||
method1(Test::<error descr="Cannot resolve method 'method2'">method2</error>);
|
||||
method1(Test::<error descr="Incompatible types: A<capture of ? super M> is not convertible to A<? super String>">method2</error>);
|
||||
}
|
||||
|
||||
static <M> void method1(B<A<? super M>> arg) { }
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import java.util.function.Predicate;
|
||||
|
||||
class MyTest {
|
||||
{
|
||||
BiConsumer<Predicate<? extends Runnable>, Predicate<? extends Runnable>> or = MyTest::<error descr="Cannot resolve method 'or'">or</error>;
|
||||
BiConsumer<Predicate<? extends Runnable>, Predicate<? extends Runnable>> or = MyTest::<error descr="Incompatible equality constraint: capture of ? extends Runnable and capture of ? extends Runnable">or</error>;
|
||||
}
|
||||
|
||||
private static <E extends Runnable> void or(Predicate<E> left, Predicate<E> right) {}
|
||||
|
||||
+6
-6
@@ -29,14 +29,14 @@ class Test {
|
||||
static void meth4(I3 s) { }
|
||||
|
||||
static {
|
||||
meth1(Foo::<error descr="Cannot resolve constructor 'Foo'">new</error>);
|
||||
meth1(Foo::<error descr="no instance(s) of type variable(s) exist so that String conforms to Number">new</error>);
|
||||
meth2(Foo::new);
|
||||
meth3(Foo::<error descr="Cannot resolve constructor 'Foo'">new</error>);
|
||||
meth3(Foo::<error descr="no instance(s) of type variable(s) exist so that Object conforms to Number">new</error>);
|
||||
meth4<error descr="Ambiguous method call: both 'Test.meth4(I1)' and 'Test.meth4(I2)' match">(Foo::new)</error>;
|
||||
|
||||
meth1(Test::<error descr="Cannot resolve method 'foo'">foo</error>);
|
||||
meth1(Test::<error descr="no instance(s) of type variable(s) exist so that String conforms to Number">foo</error>);
|
||||
meth2(Test::foo);
|
||||
meth3(Test::<error descr="Cannot resolve method 'foo'">foo</error>);
|
||||
meth3(Test::<error descr="no instance(s) of type variable(s) exist so that Object conforms to Number">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="Cannot resolve method 'fooInstance'">fooInstance</error>;
|
||||
II1 i1 = this::<error descr="no instance(s) of type variable(s) exist so that X conforms to Number">fooInstance</error>;
|
||||
II2 i2 = this::fooInstance;
|
||||
II3 i3 = this::<error descr="Cannot resolve method 'fooInstance'">fooInstance</error>;
|
||||
II3 i3 = this::<error descr="no instance(s) of type variable(s) exist so that X conforms to Number">fooInstance</error>;
|
||||
}
|
||||
}
|
||||
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
|
||||
import java.util.function.Supplier;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
|
||||
interface Regression<S, T, A, B> {
|
||||
<F extends Functor, FT extends Functor<T, F>, FB extends Functor<B, F>> FT apply(
|
||||
Function<? super A, ? extends FB> fn, S s);
|
||||
|
||||
static <S, T, A, B> Regression<S, T, A, B> regression(Function<? super S, ? extends A> getter,
|
||||
BiFunction<? super S, ? super B, ? extends T> setter) {
|
||||
return new Regression<S, T, A, B>() {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <F extends Functor, FT extends Functor<T, F>, FB extends Functor<B, F>> FT apply(
|
||||
Function<? super A, ? extends FB> fn,
|
||||
S s) {
|
||||
return null; //doesn't matter
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
static <S, A> Simple<S, A> simple(Function<? super S, ? extends A> getter,
|
||||
BiFunction<? super S, ? super A, ? extends S> setter) {
|
||||
return regression(getter, setter)::<error descr="Incompatible equality constraint: capture of ? super A and B">apply</error>; // java9 fails to compile this line
|
||||
}
|
||||
|
||||
interface Functor<X, F extends Functor> {
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
interface Simple<S, A> extends Regression<S, S, A, A> {
|
||||
}
|
||||
}
|
||||
|
||||
interface SimplifiedTest<B> {
|
||||
<FB extends Functor<B>> FB apply(Supplier<? extends FB> fn);
|
||||
|
||||
static <A> SimplifiedTest<A> simple(final SimplifiedTest<? super A> regression) {
|
||||
return regression::<error descr="no instance(s) of type variable(s) exist so that capture of ? extends FB conforms to Functor<capture of ? super A>">apply</error>;
|
||||
}
|
||||
|
||||
interface Functor<X> { }
|
||||
}
|
||||
+1
-1
@@ -4,7 +4,7 @@ class InlineRef {
|
||||
<K> void foo(Consumer<K> f) {}
|
||||
|
||||
void bar(){
|
||||
foo(Descriptor::<error descr="Cannot resolve method 'getName'">getName</error>);
|
||||
foo(Descriptor::<error descr="Incompatible types: Object is not convertible to Descriptor">getName</error>);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user