Skip to content

fix: omit parentheses around lambda body assignment expressions#951

Merged
jtkiesel merged 1 commit into
jhipster:mainfrom
jtkiesel:fix/lambda-body-assignment-parens
Jun 25, 2026
Merged

fix: omit parentheses around lambda body assignment expressions#951
jtkiesel merged 1 commit into
jhipster:mainfrom
jtkiesel:fix/lambda-body-assignment-parens

Conversation

@jtkiesel

@jtkiesel jtkiesel commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

What changed with this PR:

Lambda expression bodies that are assignment expressions are no longer wrapped in parentheses. Apparently doing so can cause the Java compiler to consider the lambda as strictly having a return value (so the lambda can no longer be used as a Consumer, for example), even though assignments always evaluate to a value, and without parentheses they can be used as the body of lambdas with or without a return value. This resolves the issue described in #921 (comment).

Example

Input

(a) -> (b = c);

Output

(a) -> b = c;

@jtkiesel jtkiesel merged commit bd01bb3 into jhipster:main Jun 25, 2026
6 checks passed
@jtkiesel jtkiesel deleted the fix/lambda-body-assignment-parens branch June 25, 2026 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant