lambda/method refs: inference exception variables (initial)

This commit is contained in:
anna
2013-02-27 12:16:34 +01:00
parent 66a91b4180
commit 6308a651a2
6 changed files with 172 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
class Test {
interface F<T extends Throwable> {
void _() throws T;
}
void m1() { }
void m2() throws ClassNotFoundException { }
void m3() throws Exception { }
<K extends Throwable> void foo1(F<K> f) throws K { }
<K extends ClassNotFoundException> void foo2(F<K> f) throws K { }
{
<error descr="Inferred type 'java.lang.RuntimeException' for type parameter 'K' is not within its bound; should extend 'java.lang.ClassNotFoundException'">foo2(()->{})</error>;
foo2(()->{ <error descr="Unhandled exception: java.lang.ClassNotFoundException">throw new ClassNotFoundException();</error> });
<error descr="Inferred type 'java.lang.RuntimeException' for type parameter 'K' is not within its bound; should extend 'java.lang.ClassNotFoundException'">foo2(this::m1)</error>;
foo2(<error descr="Unhandled exception: java.lang.ClassNotFoundException">this::m2</error>);
foo1(()->{ <error descr="Unhandled exception: java.lang.ClassNotFoundException">throw new ClassNotFoundException();</error> });
foo1(()->{ <error descr="Unhandled exception: java.lang.Exception">throw new Exception();</error> });
foo1(<error descr="Unhandled exception: java.lang.ClassNotFoundException">this::m2</error>);
foo1(<error descr="Unhandled exception: java.lang.Exception">this::m3</error>);
}
}