Skip to content

Exception formatting switch expressions #477

Closed
@Octogonapus

Description

@Octogonapus

Formatting this code:

public class A {

    public static String foo(int in) {
        return switch (in) {
            case 1 -> "A";
            case 2 -> "B";
            default -> throw new IllegalStateException("Unknown input " + in);
        };
    }
}

Produces this exception: https://pastebin.com/yQ1kt8mh

Formatting this code:

public class A {

    public static String foo(int in) {
        return switch (in) {
            case 1 -> "A";
            case 2 -> "B";
            default -> "C";
        };
    }
}

Produces this exception: https://pastebin.com/SEC77wYT

I am using version 1.8 through spotless java version 3.29.0 (latest) and running on JDK 14.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions