Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lambdas with "final var" arguments result in error: did not generate token "final" #959

Closed
bwRavencl opened this issue Aug 22, 2023 · 0 comments

Comments

@bwRavencl
Copy link

Processing lambda functions with arguments declared with final var produces: error: did not generate token "final"

Example Code:

class Test {

    public void test() {
        new File(".").listFiles((final var dir, final var name) -> true);
    }
}
$ java -jar google-java-format-1.17.0-all-deps.jar Test.java
Test.java:4:41: error: did not generate token "final"
bwRavencl added a commit to bwRavencl/ControllerBuddy that referenced this issue Aug 22, 2023
…ntir-java-format

The issue stems from google-java-format: google/google-java-format#959

This commit should be reverted once this bug is fixed in palantir-java-format!
copybara-service bot pushed a commit that referenced this issue Sep 12, 2023
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: 564460308
bwRavencl added a commit to bwRavencl/palantir-java-format that referenced this issue Sep 12, 2023
bwRavencl added a commit to bwRavencl/palantir-java-format that referenced this issue Sep 12, 2023
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 a pull request may close this issue.

1 participant