google / google/google-java-format

Native version fails to format record patterns in switches if the first nested pattern is final

Open
#1,257 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
6.2k
Forks
937
Avg merge
6m
Merged PRs (30d)
3

Description

The following code fails to format when using the native version of the formatter. (The JVM version works fine.)
```java
class Main {
void test() {
switch (test) {
case Test(final var x, final var y) -> {}
}
}
}
```

On the other hand, both of these examples are accepted:
```java
class Main {
void test() {
switch (test) {
case Test(var x, final var y) -> {}
}
}
}
```
```java
class Main {
void test() {
if (test instanceof Test(final var x, final var y)) {}
}
}
```

Tested on version 1.27.0.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.