test/tools/javac/generics/6723444/T6723444.java

Thu, 06 Jun 2013 15:33:40 +0100

author
mcimadamore
date
Thu, 06 Jun 2013 15:33:40 +0100
changeset 1811
349160289ba2
parent 611
4172cfff05f0
child 1896
44e27378f523
permissions
-rw-r--r--

8008627: Compiler mishandles three-way return-type-substitutability
Summary: Compiler should not enforce an order in how ambiguous methods should be resolved
Reviewed-by: jjg, vromero

     1 /*
     2  * @test /nodynamiccopyright/
     3  * @bug 6723444
     4  *
     5  * @summary javac fails to substitute type variables into a constructor's throws clause
     6  * @author Mark Mahieu
     7  * @compile/fail/ref=T6723444.out -XDrawDiagnostics T6723444.java
     8  *
     9  */
    10 public class T6723444 {
    12     static class Foo<X extends Throwable> {
    13         Foo() throws X {}
    14     }
    16     <X extends Throwable> T6723444()
    17         throws X {}
    19     <X extends Throwable> T6723444(Foo<X> foo)
    20         throws X {}
    22     <X1 extends Throwable, X2 extends Throwable> T6723444(Foo<X1> foo, int i)
    23         throws X1, X2 {}
    25     public static void main(String[] args) throws Exception {
    27         // the following 8 statements should compile without error
    29         Foo<Exception> exFoo = new Foo<Exception>();
    30         exFoo = new Foo<Exception>() {};
    32         new<Exception> T6723444();
    33         new<Exception> T6723444() {};
    34         new T6723444(exFoo);
    35         new T6723444(exFoo) {};
    36         new<Exception, Exception> T6723444(exFoo, 1);
    37         new<Exception, Exception> T6723444(exFoo, 1) {};
    39         // the remaining statements should all raise an
    40         // unreported exception error
    42         new T6723444(exFoo, 1);
    43         new T6723444(exFoo, 1) {};
    45         Foo<Throwable> thFoo = new Foo<Throwable>();
    46         thFoo = new Foo<Throwable>() {};
    48         new<Throwable> T6723444();
    49         new<Throwable> T6723444() {};
    50         new T6723444(thFoo);
    51         new T6723444(thFoo) {};
    52         new T6723444(thFoo, 1);
    53         new T6723444(thFoo, 1) {};
    54         new<Throwable, Throwable> T6723444(thFoo, 1);
    55         new<Throwable, Throwable> T6723444(thFoo, 1) {};
    56     }
    57 }

mercurial