7120266: javac fails to compile hotspot code
Parser changes for method references cause bad intercation with method call syntax Reviewed-by: jjg
This commit is contained in:
parent
d7cfaf1336
commit
bf0106a903
@ -1143,49 +1143,49 @@ public class JavacParser implements Parser {
|
||||
// typeArgs saved for next loop iteration.
|
||||
t = toP(F.at(pos).Select(t, ident()));
|
||||
break;
|
||||
case LT:
|
||||
if ((mode & (TYPE | NOPARAMS)) == 0) {
|
||||
//could be an unbound method reference whose qualifier
|
||||
//is a generic type i.e. A<S>#m
|
||||
mode = EXPR | TYPE;
|
||||
JCTree.Tag op = JCTree.Tag.LT;
|
||||
int pos1 = token.pos;
|
||||
nextToken();
|
||||
mode |= EXPR | TYPE | TYPEARG;
|
||||
JCExpression t1 = term3();
|
||||
if ((mode & TYPE) != 0 &&
|
||||
(token.kind == COMMA || token.kind == GT)) {
|
||||
mode = TYPE;
|
||||
ListBuffer<JCExpression> args = new ListBuffer<JCExpression>();
|
||||
args.append(t1);
|
||||
while (token.kind == COMMA) {
|
||||
nextToken();
|
||||
args.append(typeArgument());
|
||||
}
|
||||
accept(GT);
|
||||
t = toP(F.at(pos1).TypeApply(t, args.toList()));
|
||||
checkGenerics();
|
||||
while (token.kind == DOT) {
|
||||
nextToken();
|
||||
mode = TYPE;
|
||||
t = toP(F.at(token.pos).Select(t, ident()));
|
||||
t = typeArgumentsOpt(t);
|
||||
}
|
||||
if (token.kind != HASH) {
|
||||
//method reference expected here
|
||||
t = illegal();
|
||||
}
|
||||
mode = EXPR;
|
||||
break;
|
||||
} else if ((mode & EXPR) != 0) {
|
||||
//rollback - it was a binary expression
|
||||
mode = EXPR;
|
||||
JCExpression e = term2Rest(t1, TreeInfo.shiftPrec);
|
||||
t = F.at(pos1).Binary(op, t, e);
|
||||
t = termRest(term1Rest(term2Rest(t, TreeInfo.orPrec)));
|
||||
}
|
||||
}
|
||||
break loop;
|
||||
// case LT:
|
||||
// if ((mode & (TYPE | NOPARAMS)) == 0) {
|
||||
// //could be an unbound method reference whose qualifier
|
||||
// //is a generic type i.e. A<S>#m
|
||||
// mode = EXPR | TYPE;
|
||||
// JCTree.Tag op = JCTree.Tag.LT;
|
||||
// int pos1 = token.pos;
|
||||
// nextToken();
|
||||
// mode |= EXPR | TYPE | TYPEARG;
|
||||
// JCExpression t1 = term3();
|
||||
// if ((mode & TYPE) != 0 &&
|
||||
// (token.kind == COMMA || token.kind == GT)) {
|
||||
// mode = TYPE;
|
||||
// ListBuffer<JCExpression> args = new ListBuffer<JCExpression>();
|
||||
// args.append(t1);
|
||||
// while (token.kind == COMMA) {
|
||||
// nextToken();
|
||||
// args.append(typeArgument());
|
||||
// }
|
||||
// accept(GT);
|
||||
// t = toP(F.at(pos1).TypeApply(t, args.toList()));
|
||||
// checkGenerics();
|
||||
// while (token.kind == DOT) {
|
||||
// nextToken();
|
||||
// mode = TYPE;
|
||||
// t = toP(F.at(token.pos).Select(t, ident()));
|
||||
// t = typeArgumentsOpt(t);
|
||||
// }
|
||||
// if (token.kind != HASH) {
|
||||
// //method reference expected here
|
||||
// t = illegal();
|
||||
// }
|
||||
// mode = EXPR;
|
||||
// break;
|
||||
// } else if ((mode & EXPR) != 0) {
|
||||
// //rollback - it was a binary expression
|
||||
// mode = EXPR;
|
||||
// JCExpression e = term2Rest(t1, TreeInfo.shiftPrec);
|
||||
// t = F.at(pos1).Binary(op, t, e);
|
||||
// t = termRest(term1Rest(term2Rest(t, TreeInfo.orPrec)));
|
||||
// }
|
||||
// }
|
||||
// break loop;
|
||||
default:
|
||||
break loop;
|
||||
}
|
||||
|
34
langtools/test/tools/javac/T7120266.java
Normal file
34
langtools/test/tools/javac/T7120266.java
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 7120266
|
||||
* @summary javac fails to compile hotspot code
|
||||
* @compile T7120266.java
|
||||
*/
|
||||
|
||||
class T7120266 {
|
||||
void test(int i, int len) { that(i < len, "oopmap"); }
|
||||
void that(boolean b, String s) { };
|
||||
}
|
@ -24,6 +24,7 @@
|
||||
/*
|
||||
* @test
|
||||
* @bug 7115052
|
||||
* @ignore 7120266
|
||||
* @summary Add parser support for method references
|
||||
*/
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user