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

Thu, 12 Nov 2015 21:20:49 +0000

author
mcimadamore
date
Thu, 12 Nov 2015 21:20:49 +0000
changeset 3001
dcd12fa5b58a
permissions
-rw-r--r--

8066974: Compiler doesn't infer method's generic type information in lambda body
Summary: Add logic to avoid post-inference triggers on temporarty AST types
Reviewed-by: vromero

     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> { }
    12     interface Parameter {
    13         <E extends Throwable> Object m(Throwing<E> tw) throws E;
    14     }
    16     interface Mapper<R> {
    17         R m(Parameter p);
    18     }
    20     <Z> Z map(Mapper<Z> mz) { return null; }
    22     <Z extends Throwable> Mapper<Throwing<Z>> mapper(Throwing<Z> tz) throws Z { return null; }
    24     static class ThrowingMapper<X extends Throwable> implements Mapper<Throwing<X>> {
    25         ThrowingMapper(Throwing<X> arg) throws X { }
    27         @Override
    28         public Throwing<X> m(Parameter p) {
    29         return null;
    30         }
    31     }
    33     void testRuntime(RuntimeThrowing rt) {
    34         map(p->p.m(rt));
    35         map(mapper(rt));
    36         map(new ThrowingMapper<>(rt));
    37     }
    39     void testChecked(CheckedThrowing ct) {
    40         map(p->p.m(ct));
    41         map(mapper(ct));
    42         map(new ThrowingMapper<>(ct));
    43     }
    44 }

mercurial