llvm / llvm/llvm-project

[clang-format] Regression: Java field annotation forces a break after `->` in a short lambda (23 vs 22)

Open
#219,712 1 comment 0 reactions 0 assignees View on GitHub
clang-format java regression:23
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

`--style='{BasedOnStyle: Google, BreakAfterJavaFieldAnnotations: true, BreakBeforeBraces: Custom, BraceWrapping: {AfterFunction: true}}'`:

```java
class C {
@NonNull
private static final Runnable NO_OP = state -> {};
}
```

22.1.8 keeps it as written. 23.1.0:
```java
@NonNull
private static final Runnable NO_OP = state ->
{
};
```

The empty body splitting to `{`/`}` here is probably the same as #219711.

Contributor guide

Open the contributing guide

Research direction

Reproduce the provided Java snippet with the Google-based style in clang-format 22.1.8 and 23.1.0, then trace the formatting path responsible for the lambda's empty body. Done means the configured short lambda remains on one line instead of breaking after `->` and splitting its braces.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.