pertinent to applicability: process return statements inside block lambda

This commit is contained in:
Anna.Kozlova
2017-04-28 20:21:39 +02:00
parent b893701408
commit bdd3f7f3d6
4 changed files with 22 additions and 2 deletions

View File

@@ -0,0 +1,17 @@
import java.util.concurrent.Callable;
class Test {
public static void main(String[] args) throws Exception {
Runnable iteration = compute(() -> {
if (true) return () -> {};
return null;
});
Runnable iteration2 = compute(() -> () -> {});
}
static <T> T compute(Callable<T> c) throws Exception {
return c.call();
}
}

View File

@@ -16,7 +16,7 @@ class NoInferenceResult {
void test() {
m((String s1) -> <error descr="Target type of a lambda conversion must be an interface">(String s2) -> s1 + s2</error>);
m(<error descr="B is not a functional interface">(String s1) -> {return (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);