提交 b9adac00 编写于 作者: M mcimadamore

7120266: javac fails to compile hotspot code

Summary: Parser changes for method references cause bad intercation with method call syntax
Reviewed-by: jjg
上级 4a12979b
......@@ -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;
}
......
/*
* 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
*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册