T8066974.java revision 2868:816bd88d33a8
1/* 2 * @test /nodynamiccopyright/ 3 * @bug 8066974 8062373 4 * @summary Compiler doesn't infer method's generic type information in lambda body 5 * @compile/fail/ref=T8066974.out -XDrawDiagnostics T8066974.java 6 */ 7class 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 map(new ThrowingMapper<>(rt) {}); 38 } 39 40 void testChecked(CheckedThrowing ct) { 41 map(p->p.m(ct)); 42 map(mapper(ct)); 43 map(new ThrowingMapper<>(ct)); 44 map(new ThrowingMapper<>(ct) {}); 45 } 46} 47