test/tools/javac/lambda/8066974/T8066974.java

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

mercurial