Skip to content

Commit 64d97b4

Browse files
committed
Don't break empty lambda bodies
MOE_MIGRATED_REVID=138652384
1 parent 764ddff commit 64d97b4

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,15 @@ public Void visitLambdaExpression(LambdaExpressionTree node, Void unused) {
11681168
} else {
11691169
builder.breakOp(" ");
11701170
}
1171-
scan(node.getBody(), null);
1171+
if (node.getBody().getKind() == Tree.Kind.BLOCK) {
1172+
visitBlock(
1173+
(BlockTree) node.getBody(),
1174+
CollapseEmptyOrNot.YES,
1175+
AllowLeadingBlankLine.NO,
1176+
AllowTrailingBlankLine.NO);
1177+
} else {
1178+
scan(node.getBody(), null);
1179+
}
11721180
builder.close();
11731181
return null;
11741182
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class B32729600 {
2+
{
3+
f(() -> {});
4+
}
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class B32729600 {
2+
{
3+
f(() -> {});
4+
}
5+
}

0 commit comments

Comments
 (0)