mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-04 08:51:02 +07:00
lambda: do not even try to infer from return value when value depends on params
This commit is contained in:
@@ -1,17 +1,30 @@
|
||||
import java.lang.String;
|
||||
|
||||
interface I<A, B> {
|
||||
B foo(A a);
|
||||
}
|
||||
class Foo<T> {
|
||||
public <V> Foo<V> map(I<T, V> mapper) {
|
||||
return new Foo<V>();
|
||||
}
|
||||
}
|
||||
|
||||
class NoInferenceResult {
|
||||
|
||||
<A, B> I<A, B> m(I<A, B> f) { return null; }
|
||||
<T> void m1(T t) { }
|
||||
|
||||
void test() {
|
||||
m(<error descr="Incompatible return type <lambda expression> in lambda expression">(String s1) -> (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(<error descr="Incompatible return type <lambda expression> in lambda expression">(String s1) -> {return (String s2) -> s1 + s2;}</error>);
|
||||
|
||||
m((String s1) -> s1.length());
|
||||
m((String s1) -> s1);
|
||||
|
||||
m1(<error descr="Cyclic inference">() -> { }</error>);
|
||||
m1(<error descr="Cyclic inference">() -> { }</error>);
|
||||
|
||||
Foo<String> foo = new Foo<String>();
|
||||
foo.map(v -> null);
|
||||
Foo<String> map1 = foo.map(value -> value + ", " + value);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user