Skip to content

regression of issue #1008 on idea-plugin #1271

Description

@hhktseng

Previously, when Issue #1008 was reported, it was resolved.

However, with the recent update to the idea-plugin to version 1.27.0, this issue resurfaced.

This piece of code:

switch (value) {
      case 0 -> "it was 0";
      case 1 -> "it was 1";
      case 2 -> "it was 2";
      case null, default -> "unexpected value";
    };

Works fine with the CLI version of google-java-formatter, but will fail for the idea-plugin version of google-java-formatter.

The only solution is to revert the above switch pattern into

      case null -> "null value";
      default -> "unexpected value";

A simple class to allow easy testing of this

public class Test {
    public static void main(String[] args) {
        Object obj = null; // or some other object
        String result = switch (obj) {
            case null, default -> "handled";
        };
        System.out.println(result);
    }
}

JDK Used: https://adoptium.net/en-GB/temurin/releases/?version=21

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions