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

Not support java 21 switch record #1020

Closed
paomian opened this issue Dec 29, 2023 · 1 comment
Closed

Not support java 21 switch record #1020

paomian opened this issue Dec 29, 2023 · 1 comment

Comments

@paomian
Copy link

paomian commented Dec 29, 2023

cat > a.java <<'EOL'
public sealed interface A {
    record AA(Long a) implements A {}
    record AAA(String b) implements A {}
    static Long mySwitch(A a) {
        switch (a) {
            case AA(var aa) -> {
                return aa;
            }
            case AAA(var b) -> {
                return Long.parseLong(b);
            }
        }
    }
}
EOL

java -jar google-java-format-1.19.1-all-deps.jar -r a.java
a.java:6:22: error: expected token: 'var'; generated aa instead
copybara-service bot pushed a commit that referenced this issue Jan 4, 2024
#1020

PiperOrigin-RevId: 595517489
copybara-service bot pushed a commit that referenced this issue Jan 4, 2024
#1020

PiperOrigin-RevId: 595517489
copybara-service bot pushed a commit that referenced this issue Jan 4, 2024
#1020

PiperOrigin-RevId: 595537430
@cushon
Copy link
Collaborator

cushon commented Jan 5, 2024

This is fixed in https://github.com/google/google-java-format/releases/tag/v1.19.2

@cushon cushon closed this as completed Jan 5, 2024
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

No branches or pull requests

2 participants