author | mcimadamore |
Thu, 18 Dec 2014 13:21:44 +0000 | |
changeset 28148 | 6415a95b07fd |
child 29776 | 984a79b71cfe |
permissions | -rw-r--r-- |
28148
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
1 |
/* |
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
2 |
* @test /nodynamiccopyright/ |
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
3 |
* @bug 8066974 |
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
4 |
* @summary Compiler doesn't infer method's generic type information in lambda body |
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
5 |
* @compile/fail/ref=T8066974.out -XDrawDiagnostics T8066974.java |
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
6 |
*/ |
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
7 |
class T8066974 { |
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
8 |
static class Throwing<E extends Throwable> { } |
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
9 |
static class RuntimeThrowing extends Throwing<RuntimeException> { } |
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
10 |
static class CheckedThrowing extends Throwing<Exception> { } |
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
11 |
|
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
12 |
interface Parameter { |
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
13 |
<E extends Throwable> Object m(Throwing<E> tw) throws E; |
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
14 |
} |
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
15 |
|
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
16 |
interface Mapper<R> { |
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
17 |
R m(Parameter p); |
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
18 |
} |
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
19 |
|
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
20 |
<Z> Z map(Mapper<Z> mz) { return null; } |
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
21 |
|
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
22 |
<Z extends Throwable> Mapper<Throwing<Z>> mapper(Throwing<Z> tz) throws Z { return null; } |
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
23 |
|
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
24 |
static class ThrowingMapper<X extends Throwable> implements Mapper<Throwing<X>> { |
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
25 |
ThrowingMapper(Throwing<X> arg) throws X { } |
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
26 |
|
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
27 |
@Override |
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
28 |
public Throwing<X> m(Parameter p) { |
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
29 |
return null; |
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
30 |
} |
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
31 |
} |
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
32 |
|
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
33 |
void testRuntime(RuntimeThrowing rt) { |
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
34 |
map(p->p.m(rt)); |
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
35 |
map(mapper(rt)); |
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
36 |
map(new ThrowingMapper<>(rt)); |
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
37 |
} |
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
38 |
|
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
39 |
void testChecked(CheckedThrowing ct) { |
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
40 |
map(p->p.m(ct)); |
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
41 |
map(mapper(ct)); |
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
42 |
map(new ThrowingMapper<>(ct)); |
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
43 |
} |
6415a95b07fd
8066974: Compiler doesn't infer method's generic type information in lambda body
mcimadamore
parents:
diff
changeset
|
44 |
} |