Description
Upstream: google/google-java-format#1505
Kind: idea | Priority: low
google-java-format#1505 (merged 2026-10-29, copybara export) teaches the --cleanup pass to rewrite (x) -> x as x -> x. Comments inside the parentheses are preserved, and a space is added when the opening parenthesis follows an identifier (return(x) -> x). It answers the old request google-java-format#762, which was closed on 2026-10-29.
Why it matters: a common style nit that our formatter leaves alone. Like the other cleanup tickets it only makes sense if we add an AST cleanup pass.
Before (upstream behaviour before the change; I believe ours keeps the parentheses but did not run it):
class T {
Function<Integer, Integer> f = (x) -> x + 1;
Runnable r = () -> {};
}After (with the change, from the upstream description):
class T {
Function<Integer, Integer> f = x -> x + 1;
Runnable r = () -> {};
}Affected files in our repo:
- open-java-format/src/main/java/com/palantir/javaformat/java/Formatter.java (where a cleanup pass would be wired in)
Suggested action: watch together with the other cleanup tickets; only typed or multi-parameter lambdas must keep their parentheses.
Filed from an upstream-watch ticket after manual review.
Activity