diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java index c8e0918d76c..b84d375d5ae 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java @@ -239,7 +239,6 @@ protected DocCommentTable newDocCommentTable(boolean keepDocComments, ParserFact * mode = NOPARAMS : no parameters allowed for type * mode = TYPEARG : type argument * mode |= NOLAMBDA : lambdas are not allowed - * mode |= NOINVOCATION : method invocations are not allowed */ protected static final int EXPR = 0x1; protected static final int TYPE = 0x2; @@ -247,14 +246,13 @@ protected DocCommentTable newDocCommentTable(boolean keepDocComments, ParserFact protected static final int TYPEARG = 0x8; protected static final int DIAMOND = 0x10; protected static final int NOLAMBDA = 0x20; - protected static final int NOINVOCATION = 0x40; protected void selectExprMode() { - mode = (mode & (NOLAMBDA | NOINVOCATION)) | EXPR; + mode = (mode & NOLAMBDA) | EXPR; } protected void selectTypeMode() { - mode = (mode & (NOLAMBDA | NOINVOCATION)) | TYPE; + mode = (mode & NOLAMBDA) | TYPE; } /** The current mode. @@ -1368,7 +1366,7 @@ protected JCExpression term3() { } break loop; case LPAREN: - if ((mode & EXPR) != 0 && (mode & NOINVOCATION) == 0) { + if ((mode & EXPR) != 0) { selectExprMode(); t = arguments(typeArgs, t); if (!annos.isEmpty()) t = illegal(annos.head.pos); @@ -3181,7 +3179,9 @@ PatternResult analyzePattern(int lookahead) { } case LPAREN: if (S.token(lookahead + 1).kind == RPAREN) { - return PatternResult.PATTERN; + return parentDepth != 0 && S.token(lookahead + 2).kind == ARROW + ? PatternResult.EXPRESSION + : PatternResult.PATTERN; } parentDepth++; break; case RPAREN: parentDepth--; break;