lambda: inference param types for assignment and cast context

This commit is contained in:
anna
2012-07-19 12:15:41 +02:00
parent 6b99ef5e9e
commit 5bb4a61bb9
9 changed files with 156 additions and 38 deletions
@@ -27,13 +27,13 @@ class C {
}
void test() {
Simplest simplest = <weak_warning descr="Lambda expressions type check is not yet implemented">() -> { }</weak_warning>;
Simplest simplest = () -> { };
use(<weak_warning descr="Lambda expressions type check is not yet implemented">() -> { }</weak_warning>);
IntParser intParser = <weak_warning descr="Lambda expressions type check is not yet implemented">(String s) -> Integer.parseInt(s)</weak_warning>;
IntParser intParser = (String s) -> Integer.parseInt(s);
}
Runnable foo() {
return <weak_warning descr="Lambda expressions type check is not yet implemented">() -> { System.out.println("foo"); }</weak_warning>;
return () -> { System.out.println("foo"); };
}
}
@@ -0,0 +1,12 @@
interface I {
void m(int i);
}
class Foo {
I ii = (@<error descr="'@Override' not applicable to type use">Override</error> final int k)->{
int j = k;
};
I ii1 = (final int k)->{
<error descr="Incompatible types. Found: 'int', required: 'java.lang.String'">String s = k;</error>
};
}
@@ -0,0 +1,23 @@
import java.lang.String;
interface I {
void m(int i);
}
interface A<B> {
void foo(B b);
}
class Foo {
I ii = (final <error descr="Cannot resolve symbol 'k'">k</error><error descr="Identifier expected">)</error>->{};
I ii1 = (k)->{
int i = k;
<error descr="Incompatible types. Found: 'int', required: 'java.lang.String'">String s = k;</error>
};
A<String> a = (ab) -> {
String s = ab;
<error descr="Incompatible types. Found: 'java.lang.String', required: 'int'">int i = ab;</error>
};
}