Maurizio Cimadamore a65f240258 8141343: Subtle semantics changes for union types in cast conversion
Cast applied to union types do not behave correctly and sometimes pass erroneously

Reviewed-by: jlahoda
2015-11-05 11:32:01 +00:00

26 lines
614 B
Java

/*
* @test /nodynamiccopyright/
* @bug 8141343
* @summary Subtle semantics changes for union types in cast conversion
* @compile/fail/ref=T8141343.out -XDrawDiagnostics T8141343.java
*/
class T8141343 {
interface Foo<X> { }
static class A extends Exception implements Foo<A> { }
static class B extends Exception implements Foo<B> { }
void test(boolean cond) {
try {
if (cond) {
throw new A();
} else {
throw new B();
}
} catch (A | B ex) {
Foo<Integer> fa = (Foo<Integer>)ex;
}
}
}