recursive lambda checks for functional interfaces

This commit is contained in:
anna
2013-08-06 13:49:09 +02:00
parent 94f4462b36
commit 1bd39a6322
7 changed files with 31 additions and 14 deletions
@@ -22,6 +22,6 @@ class CastInContexts {
}
{
int i = <error descr="Inconvertible types; cannot cast '<lambda expression>' to 'int'">(int) ()-> 1</error>;
int i = (int) <error descr="int is not a functional interface">()-> 1</error>;
}
}
@@ -0,0 +1,5 @@
class Demo {
public static void main(String[] args) {
Runnable r = () -> <error descr="void is not a functional interface">() -> () -> {}</error>;
}
}
@@ -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="Incompatible return type <lambda expression> in lambda expression">(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);
@@ -48,7 +48,7 @@ class Test2 {
}
{
X<?> x = <error descr="No instance of type X<?> exists so that lambda expression can be type-checked">() -> 123</error>;
X<?> x = () -> 123;
X<? extends Number> x1 = () -> 123;
}