Skip to content

Commit

Permalink
GROOVY-10236
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Sep 18, 2021
1 parent 4665fa1 commit d498406
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ public void testLambdaBasic() {
"Supplier<String> s = () -> 'hello'\n" +
"print s.get()\n" +
"\n" +
"Consumer<String> c = x -> print(x)\n" +
"Consumer<String> c = (x -> print x)\n" + // GROOVY-10236
"c.accept(' ')\n" +
"\n" +
"Function<Integer, String> f = (Integer i) -> { 'world' }\n" +
Expand Down
2 changes: 1 addition & 1 deletion base/org.codehaus.groovy40/src/GroovyParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ standardLambdaParameters

lambdaBody
: block
| expression
| statementExpression
;

// CLOSURE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4274,15 +4274,10 @@ public Parameter[] visitStandardLambdaParameters(final StandardLambdaParametersC

@Override
public Statement visitLambdaBody(final LambdaBodyContext ctx) {
if (asBoolean(ctx.expression())) {
return configureAST(new ExpressionStatement((Expression) this.visit(ctx.expression())), ctx);
}

if (asBoolean(ctx.block())) {
return configureAST(this.visitBlock(ctx.block()), ctx);
}

throw createParsingFailedException("Unsupported lambda body: " + ctx.getText(), ctx);
return configureAST((Statement) this.visit(ctx.statementExpression()), ctx);
}

@Override
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4622,8 +4622,8 @@ public static class LambdaBodyContext extends GroovyParserRuleContext {
public BlockContext block() {
return getRuleContext(BlockContext.class,0);
}
public ExpressionContext expression() {
return getRuleContext(ExpressionContext.class,0);
public StatementExpressionContext statementExpression() {
return getRuleContext(StatementExpressionContext.class,0);
}
public LambdaBodyContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
Expand Down Expand Up @@ -4656,7 +4656,7 @@ public final LambdaBodyContext lambdaBody() throws RecognitionException {
enterOuterAlt(_localctx, 2);
{
setState(869);
expression(0);
statementExpression();
}
break;
}
Expand Down Expand Up @@ -13420,7 +13420,7 @@ private boolean pathExpression_sempred(PathExpressionContext _localctx, int pred
"\5\u0146\u00a4\2\u035e\u035f\5\u0082B\2\u035f}\3\2\2\2\u0360\u0361\5^"+
"\60\2\u0361\177\3\2\2\2\u0362\u0365\5^\60\2\u0363\u0365\5@!\2\u0364\u0362"+
"\3\2\2\2\u0364\u0363\3\2\2\2\u0365\u0081\3\2\2\2\u0366\u0369\5\u009eP"+
"\2\u0367\u0369\5\u00f0y\2\u0368\u0366\3\2\2\2\u0368\u0367\3\2\2\2\u0369"+
"\2\u0367\u0369\5\u00e6t\2\u0368\u0366\3\2\2\2\u0368\u0367\3\2\2\2\u0369"+
"\u0083\3\2\2\2\u036a\u0373\7Y\2\2\u036b\u036f\5\u0146\u00a4\2\u036c\u036d"+
"\5`\61\2\u036d\u036e\5\u0146\u00a4\2\u036e\u0370\3\2\2\2\u036f\u036c\3"+
"\2\2\2\u036f\u0370\3\2\2\2\u0370\u0371\3\2\2\2\u0371\u0372\7T\2\2\u0372"+
Expand Down

0 comments on commit d498406

Please sign in to comment.