new inference: infer from thrown exceptions in lambda body

(cherry picked from commit 04056c01aa1eef1239ac88d48baec7ff109ef0df)
This commit is contained in:
anna
2013-11-20 11:46:32 +01:00
parent 709b6166be
commit 19852e61cd
4 changed files with 30 additions and 3 deletions

View File

@@ -0,0 +1,21 @@
class Test {
interface I<E extends Throwable> {
void foo() throws E;
}
static class Ex extends Exception {}
<E extends Throwable> void bar(I<E> s) throws E {
s.foo();
}
void baz(I<Ex> s) throws Ex {
bar(() -> {
try {
s.foo();
} catch (Throwable t) {
throw t;
}
});
bar(() -> s.foo());
}
}

View File

@@ -20,8 +20,8 @@ class Test {
foo1(()->{ <error descr="Unhandled exception: java.lang.ClassNotFoundException">throw new ClassNotFoundException();</error> });
foo1(()->{ <error descr="Unhandled exception: java.lang.Exception">throw new Exception();</error> });
<error descr="Unhandled exception: java.lang.ClassNotFoundException">foo1(()->{ throw new ClassNotFoundException(); });</error>
<error descr="Unhandled exception: java.lang.Exception">foo1(()->{ throw new Exception(); });</error>
<error descr="Unhandled exception: java.lang.ClassNotFoundException">foo1(this::m2);</error>
<error descr="Unhandled exception: java.lang.Exception">foo1(this::m3);</error>