Skip to content

Commit

Permalink
Cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
lahodaj committed May 2, 2022
1 parent 6e702c5 commit 5d300fd
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,22 +239,20 @@ 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;
protected static final int NOPARAMS = 0x4;
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.
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 5d300fd

Please sign in to comment.