test/tools/javac/cast/6665356/T6665356.java

Tue, 13 Jan 2009 13:28:20 +0000

author
mcimadamore
date
Tue, 13 Jan 2009 13:28:20 +0000
changeset 185
d57378c34fdb
child 229
03bcd66bd8e7
permissions
-rw-r--r--

6665356: Cast not allowed when both qualifying type and inner class are parameterized
Summary: Fixed parser and cats conversion in order to allow cast between generic inner classes
Reviewed-by: jjg

mcimadamore@185 1 /*
mcimadamore@185 2 * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
mcimadamore@185 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
mcimadamore@185 4 *
mcimadamore@185 5 * This code is free software; you can redistribute it and/or modify it
mcimadamore@185 6 * under the terms of the GNU General Public License version 2 only, as
mcimadamore@185 7 * published by the Free Software Foundation.
mcimadamore@185 8 *
mcimadamore@185 9 * This code is distributed in the hope that it will be useful, but WITHOUT
mcimadamore@185 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
mcimadamore@185 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
mcimadamore@185 12 * version 2 for more details (a copy is included in the LICENSE file that
mcimadamore@185 13 * accompanied this code).
mcimadamore@185 14 *
mcimadamore@185 15 * You should have received a copy of the GNU General Public License version
mcimadamore@185 16 * 2 along with this work; if not, write to the Free Software Foundation,
mcimadamore@185 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
mcimadamore@185 18 *
mcimadamore@185 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
mcimadamore@185 20 * CA 95054 USA or visit www.sun.com if you need additional information or
mcimadamore@185 21 * have any questions.
mcimadamore@185 22 */
mcimadamore@185 23
mcimadamore@185 24 /*
mcimadamore@185 25 * @test
mcimadamore@185 26 * @author Maurizio Cimadamore
mcimadamore@185 27 * @bug 6665356
mcimadamore@185 28 * @summary Cast not allowed when both qualifying type and inner class are parameterized
mcimadamore@185 29 * @compile/fail/ref=T6665356.out -XDrawDiagnostics T6665356.java
mcimadamore@185 30 */
mcimadamore@185 31
mcimadamore@185 32 class T6665356 {
mcimadamore@185 33 class Outer<S> {
mcimadamore@185 34 class Inner<T> {}
mcimadamore@185 35 }
mcimadamore@185 36
mcimadamore@185 37 void cast1(Outer<Integer>.Inner<Long> p) {
mcimadamore@185 38 Object o = (Outer<Integer>.Inner<Long>)p;
mcimadamore@185 39 }
mcimadamore@185 40
mcimadamore@185 41 void cast2(Outer<Integer>.Inner<Long> p) {
mcimadamore@185 42 Object o = (Outer<? extends Number>.Inner<Long>)p;
mcimadamore@185 43 }
mcimadamore@185 44
mcimadamore@185 45 void cast3(Outer<Integer>.Inner<Long> p) {
mcimadamore@185 46 Object o = (Outer<Integer>.Inner<? extends Number>)p;
mcimadamore@185 47 }
mcimadamore@185 48
mcimadamore@185 49 void cast4(Outer<Integer>.Inner<Long> p) {
mcimadamore@185 50 Object o = (Outer<? extends Number>.Inner<? extends Number>)p;
mcimadamore@185 51 }
mcimadamore@185 52
mcimadamore@185 53 void cast5(Outer<Integer>.Inner<Long> p) {
mcimadamore@185 54 Object o = (Outer<? super Number>.Inner<Long>)p;
mcimadamore@185 55 }
mcimadamore@185 56
mcimadamore@185 57 void cast6(Outer<Integer>.Inner<Long> p) {
mcimadamore@185 58 Object o = (Outer<Integer>.Inner<? super Number>)p;
mcimadamore@185 59 }
mcimadamore@185 60
mcimadamore@185 61 void cast7(Outer<Integer>.Inner<Long> p) {
mcimadamore@185 62 Object o = (Outer<? super Number>.Inner<? super Number>)p;
mcimadamore@185 63 }
mcimadamore@185 64
mcimadamore@185 65 void cast8(Outer<Integer>.Inner<Long> p) {
mcimadamore@185 66 Object o = (Outer<? extends String>.Inner<Long>)p;
mcimadamore@185 67 }
mcimadamore@185 68
mcimadamore@185 69 void cast9(Outer<Integer>.Inner<Long> p) {
mcimadamore@185 70 Object o = (Outer<Integer>.Inner<? extends String>)p;
mcimadamore@185 71 }
mcimadamore@185 72
mcimadamore@185 73 void cast10(Outer<Integer>.Inner<Long> p) {
mcimadamore@185 74 Object o = (Outer<? super String>.Inner<Long>)p;
mcimadamore@185 75 }
mcimadamore@185 76
mcimadamore@185 77 void cast11(Outer<Integer>.Inner<Long> p) {
mcimadamore@185 78 Object o = (Outer<Integer>.Inner<? super String>)p;
mcimadamore@185 79 }
mcimadamore@185 80 }

mercurial