new overload resolution: reject complete normally when last instruction is return (IDEA-134808)

This commit is contained in:
Anna Kozlova
2014-12-29 14:05:30 +01:00
parent fe898d0905
commit 658607d9c2
3 changed files with 70 additions and 2 deletions

View File

@@ -0,0 +1,58 @@
class Test {
public interface A<E extends Throwable> {
Object call() throws E;
}
public interface B<E extends Throwable> {
void call() throws E;
}
static Object method(A lambda) {
System.out.println("A::");
try {
lambda.call();
} catch (Throwable throwable) {
throwable.printStackTrace();
}
return null;
}
static void method(B lambda) {
System.out.println("B::");
try {
lambda.call();
} catch (Throwable throwable) {
throwable.printStackTrace();
}
}
static Object returns(String s) throws Exception {
System.out.println(s); return null;
}
static void voids(String s) throws Exception {
System.out.println(s);
}
public static void main(String[] args) {
method(() -> {
voids("-> B");
});
method(() -> voids("-> B"));
method(() -> {
return returns("-> A");
});
method(() -> returns("-> A") );
method(() -> {
returns("-> B");
});
}
}