Skip to content

Commit

Permalink
Handle final var lambda variables
Browse files Browse the repository at this point in the history
The start position of `final` variable is apparently after the token for
`final`, this works around that by inlining a call to `visitVariable` and
dropping the `sync` call that asserts the start position of the current
node matches the next token.

Fixes #959

PiperOrigin-RevId: 564710136
  • Loading branch information
cushon authored and google-java-format Team committed Sep 12, 2023
1 parent d0e44e5 commit 1fe6789
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1250,7 +1250,10 @@ public Void visitLambdaExpression(LambdaExpressionTree node, Void unused) {
token(",");
builder.breakOp(" ");
}
scan(parameter, null);
visitVariables(
ImmutableList.of(parameter),
DeclarationKind.NONE,
fieldAnnotationDirection(parameter.getModifiers()));
first = false;
}
if (parens) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class I959 {
public void test() {
new File(".").listFiles((final var dir, final var name) -> true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class I959 {
public void test() {
new File(".").listFiles((final var dir, final var name) -> true);
}
}

0 comments on commit 1fe6789

Please sign in to comment.