author | mcimadamore |
Thu, 05 Nov 2015 11:32:01 +0000 | |
changeset 33556 | a14a556cf2c9 |
permissions | -rw-r--r-- |
33556
a14a556cf2c9
8141343: Subtle semantics changes for union types in cast conversion
mcimadamore
parents:
diff
changeset
|
1 |
/* |
a14a556cf2c9
8141343: Subtle semantics changes for union types in cast conversion
mcimadamore
parents:
diff
changeset
|
2 |
* @test /nodynamiccopyright/ |
a14a556cf2c9
8141343: Subtle semantics changes for union types in cast conversion
mcimadamore
parents:
diff
changeset
|
3 |
* @bug 8141343 |
a14a556cf2c9
8141343: Subtle semantics changes for union types in cast conversion
mcimadamore
parents:
diff
changeset
|
4 |
* @summary Subtle semantics changes for union types in cast conversion |
a14a556cf2c9
8141343: Subtle semantics changes for union types in cast conversion
mcimadamore
parents:
diff
changeset
|
5 |
* @compile/fail/ref=T8141343.out -XDrawDiagnostics T8141343.java |
a14a556cf2c9
8141343: Subtle semantics changes for union types in cast conversion
mcimadamore
parents:
diff
changeset
|
6 |
*/ |
a14a556cf2c9
8141343: Subtle semantics changes for union types in cast conversion
mcimadamore
parents:
diff
changeset
|
7 |
|
a14a556cf2c9
8141343: Subtle semantics changes for union types in cast conversion
mcimadamore
parents:
diff
changeset
|
8 |
class T8141343 { |
a14a556cf2c9
8141343: Subtle semantics changes for union types in cast conversion
mcimadamore
parents:
diff
changeset
|
9 |
interface Foo<X> { } |
a14a556cf2c9
8141343: Subtle semantics changes for union types in cast conversion
mcimadamore
parents:
diff
changeset
|
10 |
|
a14a556cf2c9
8141343: Subtle semantics changes for union types in cast conversion
mcimadamore
parents:
diff
changeset
|
11 |
static class A extends Exception implements Foo<A> { } |
a14a556cf2c9
8141343: Subtle semantics changes for union types in cast conversion
mcimadamore
parents:
diff
changeset
|
12 |
static class B extends Exception implements Foo<B> { } |
a14a556cf2c9
8141343: Subtle semantics changes for union types in cast conversion
mcimadamore
parents:
diff
changeset
|
13 |
|
a14a556cf2c9
8141343: Subtle semantics changes for union types in cast conversion
mcimadamore
parents:
diff
changeset
|
14 |
void test(boolean cond) { |
a14a556cf2c9
8141343: Subtle semantics changes for union types in cast conversion
mcimadamore
parents:
diff
changeset
|
15 |
try { |
a14a556cf2c9
8141343: Subtle semantics changes for union types in cast conversion
mcimadamore
parents:
diff
changeset
|
16 |
if (cond) { |
a14a556cf2c9
8141343: Subtle semantics changes for union types in cast conversion
mcimadamore
parents:
diff
changeset
|
17 |
throw new A(); |
a14a556cf2c9
8141343: Subtle semantics changes for union types in cast conversion
mcimadamore
parents:
diff
changeset
|
18 |
} else { |
a14a556cf2c9
8141343: Subtle semantics changes for union types in cast conversion
mcimadamore
parents:
diff
changeset
|
19 |
throw new B(); |
a14a556cf2c9
8141343: Subtle semantics changes for union types in cast conversion
mcimadamore
parents:
diff
changeset
|
20 |
} |
a14a556cf2c9
8141343: Subtle semantics changes for union types in cast conversion
mcimadamore
parents:
diff
changeset
|
21 |
} catch (A | B ex) { |
a14a556cf2c9
8141343: Subtle semantics changes for union types in cast conversion
mcimadamore
parents:
diff
changeset
|
22 |
Foo<Integer> fa = (Foo<Integer>)ex; |
a14a556cf2c9
8141343: Subtle semantics changes for union types in cast conversion
mcimadamore
parents:
diff
changeset
|
23 |
} |
a14a556cf2c9
8141343: Subtle semantics changes for union types in cast conversion
mcimadamore
parents:
diff
changeset
|
24 |
} |
a14a556cf2c9
8141343: Subtle semantics changes for union types in cast conversion
mcimadamore
parents:
diff
changeset
|
25 |
} |