new overload resolution: void value compatibility to reject improperly shaped implicitly typed lambdas

This commit is contained in:
Anna Kozlova
2014-09-03 16:12:15 +04:00
parent 343b444a24
commit 9097465506
4 changed files with 76 additions and 19 deletions

View File

@@ -0,0 +1,23 @@
interface A {
int m(int x);
}
interface B {
void m(boolean x);
}
abstract class Test {
abstract void foo(A j);
abstract void foo(B i);
void bar(Object o) {
foo(x -> {
return x += 1;
});
foo(x -> <error descr="Incompatible types. Found: 'int', required: '<lambda parameter>'">x += 1</error>);
foo(x -> 1);
foo(x -> <error descr="Operator '!' cannot be applied to 'int'">!x</error>);
foo(x -> <error descr="Operator '++' cannot be applied to '<lambda parameter>'">++x</error>);
foo(x -> o instanceof String ? 1 : 0);
}
}