lambda constraints: proceed with return expressions (IDEA-175426)

lambda with formal types won't lead to additional constraint after return type constraint processing, thus it need to be processed additionally
This commit is contained in:
Anna.Kozlova
2017-07-05 16:48:52 +02:00
parent 3fb6d0d61a
commit 9e0394a757
4 changed files with 24 additions and 4 deletions
@@ -15,8 +15,8 @@ class NoInferenceResult {
<T> void m1(T t) { }
void test() {
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(<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) -> s1.length());
m((String s1) -> s1);
@@ -0,0 +1,20 @@
import java.io.IOException;
import java.util.Optional;
class GenericClass {
<E extends Throwable> void build(Test<E, Optional<Integer>> test) { }
{
build((IOException ex) -> returnOptional());
}
private static <T> Optional<T> returnOptional() {
return null;
}
@FunctionalInterface
interface Test<E, T> {
T evaluate(E ex);
}
}