langtools/test/tools/javac/generics/6531090/T6531090b.java
changeset 326 d51f30ce6796
child 1528 441d4ec466de
equal deleted inserted replaced
325:44df0e9643b4 326:d51f30ce6796
       
     1 /*
       
     2  * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.
       
     8  *
       
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    12  * version 2 for more details (a copy is included in the LICENSE file that
       
    13  * accompanied this code).
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License version
       
    16  * 2 along with this work; if not, write to the Free Software Foundation,
       
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    18  *
       
    19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
       
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
       
    21  * have any questions.
       
    22  */
       
    23 
       
    24 /*
       
    25  * @test
       
    26  * @bug 6531090
       
    27  *
       
    28  * @summary Cannot access methods/fields of a captured type belonging to an intersection type
       
    29  * @author Maurizio Cimadamore
       
    30  *
       
    31  */
       
    32 public class T6531090b {
       
    33 
       
    34     static class A {
       
    35         public void a() {}
       
    36         public A a;
       
    37     }
       
    38     static class B extends A {
       
    39         public void b(){}
       
    40         public B b;
       
    41     }
       
    42     static interface I{
       
    43         void i();
       
    44     }
       
    45     static interface I1{
       
    46         void i1();
       
    47     }
       
    48     static class E extends B implements I, I1{
       
    49         public void i() {}
       
    50         public void i1() {}
       
    51     }
       
    52     static class C<W extends B & I1, T extends W>{
       
    53         T t;
       
    54         W w;
       
    55         C(W w, T t) {
       
    56             this.w = w;
       
    57             this.t = t;
       
    58         }
       
    59     }
       
    60 
       
    61     public static void main(String... args) {
       
    62         C<E,E> c = new C<E,E>(new E(), new E());
       
    63         testMemberMethods(c);
       
    64         testMemberFields(c);
       
    65     }
       
    66 
       
    67     static void testMemberMethods(C<? extends A, ? extends I> arg) {
       
    68         arg.t.a();
       
    69         arg.t.b();
       
    70         arg.t.i1();
       
    71         arg.w.a();
       
    72         arg.w.b();
       
    73         arg.w.i1();
       
    74     }
       
    75 
       
    76     static void testMemberFields(C<? extends A, ? extends I> arg) {
       
    77         A ta = arg.t.a;
       
    78         B tb = arg.t.b;
       
    79         A wa = arg.w.a;
       
    80         B wb = arg.w.b;
       
    81     }
       
    82 }