diff --git a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java index ef48f23984fa474877e2813a9bc91e8852bb4cec..a1bd2da6e555db89e5f330bc0e1348a882c8593d 100644 --- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java +++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java @@ -863,13 +863,13 @@ public class JavacParser implements Parser { accept(GT); t = F.at(pos1).TypeApply(t, args.toList()); checkGenerics(); - t = bracketsOpt(toP(t)); while (S.token() == DOT) { S.nextToken(); mode = TYPE; t = toP(F.at(S.pos()).Select(t, ident())); t = typeArgumentsOpt(t); } + t = bracketsOpt(toP(t)); } else if ((mode & EXPR) != 0) { mode = EXPR; t = F.at(pos1).Binary(op, t, term2Rest(t1, TreeInfo.shiftPrec)); diff --git a/test/tools/javac/cast/6795580/T6795580.java b/test/tools/javac/cast/6795580/T6795580.java new file mode 100644 index 0000000000000000000000000000000000000000..9539e32e0df94e6d6bf894b7d797ef6ab7a0d00a --- /dev/null +++ b/test/tools/javac/cast/6795580/T6795580.java @@ -0,0 +1,80 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @author Maurizio Cimadamore + * @bug 6795580 + * @summary parser confused by square brackets in qualified generic cast + * @compile/fail/ref=T6795580.out -XDrawDiagnostics T6795580.java + */ + +class T6795580 { + class Outer { + class Inner {} + } + + void cast1(Outer.Inner[] p) { + Object o = (Outer.Inner[])p; + } + + void cast2(Outer.Inner[] p) { + Object o = (Outer.Inner[])p; + } + + void cast3(Outer.Inner[] p) { + Object o = (Outer.Inner[])p; + } + + void cast4(Outer.Inner[] p) { + Object o = (Outer.Inner[])p; + } + + void cast5(Outer.Inner[] p) { + Object o = (Outer.Inner[])p; + } + + void cast6(Outer.Inner[] p) { + Object o = (Outer.Inner[])p; + } + + void cast7(Outer.Inner[] p) { + Object o = (Outer.Inner[])p; + } + + void cast8(Outer.Inner[] p) { + Object o = (Outer.Inner[])p; + } + + void cast9(Outer.Inner[] p) { + Object o = (Outer.Inner[])p; + } + + void cast10(Outer.Inner[] p) { + Object o = (Outer.Inner[])p; + } + + void cast11(Outer.Inner[] p) { + Object o = (Outer.Inner[])p; + } +} \ No newline at end of file diff --git a/test/tools/javac/cast/6795580/T6795580.out b/test/tools/javac/cast/6795580/T6795580.out new file mode 100644 index 0000000000000000000000000000000000000000..f754e1dc2c5351cde251574d57600a58cb49acb4 --- /dev/null +++ b/test/tools/javac/cast/6795580/T6795580.out @@ -0,0 +1,8 @@ +T6795580.java:54:57: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6795580.Outer.Inner[], T6795580.Outer.Inner[] +T6795580.java:58:60: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6795580.Outer.Inner[], T6795580.Outer.Inner[] +T6795580.java:62:67: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6795580.Outer.Inner[], T6795580.Outer.Inner[] +T6795580.java:66:59: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6795580.Outer.Inner[], T6795580.Outer.Inner[] +T6795580.java:70:62: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6795580.Outer.Inner[], T6795580.Outer.Inner[] +T6795580.java:74:57: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6795580.Outer.Inner[], T6795580.Outer.Inner[] +T6795580.java:78:60: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6795580.Outer.Inner[], T6795580.Outer.Inner[] +7 errors