langtools/test/tools/javac/generics/6531090/T6531090a.java
author mcimadamore
Wed, 02 Apr 2008 11:44:23 +0100
changeset 326 d51f30ce6796
child 5520 86e4b9a9da40
permissions -rw-r--r--
6531090: Cannot access methods/fields of a captured type belonging to an intersection type Summary: fixed lookup of field/methods on intersection types Reviewed-by: jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
326
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
     1
/*
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
     2
 * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
     4
 *
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
     7
 * published by the Free Software Foundation.
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
     8
 *
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    13
 * accompanied this code).
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    14
 *
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    18
 *
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    21
 * have any questions.
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    22
 */
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    23
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    24
/*
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    25
 * @test
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    26
 * @bug 6531090
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    27
 *
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    28
 * @summary Cannot access methods/fields of a captured type belonging to an intersection type
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    29
 * @author Maurizio Cimadamore
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    30
 *
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    31
 */
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    32
public class T6531090a {
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    33
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    34
    static class E {}
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    35
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    36
    static class F extends E implements I1 {}
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    37
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    38
    static interface I {}
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    39
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    40
    static interface I1 {}
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    41
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    42
    static class G extends F implements I {}
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    43
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    44
    static class C<T extends E & I> {
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    45
        T field;
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    46
    }
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    47
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    48
    public static void main(String... args) {
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    49
        test(new C<G>());
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    50
    }
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    51
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    52
    static <W extends F> void test(C<? extends W> arg) {
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    53
        F vf = arg.field;
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    54
        I vi = arg.field;
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    55
        I1 vi1 = arg.field;
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    56
        E ve = arg.field;
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    57
        W vt = arg.field;
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    58
    }
d51f30ce6796 6531090: Cannot access methods/fields of a captured type belonging to an intersection type
mcimadamore
parents:
diff changeset
    59
}