Skip to content

Formatting fails with unnamed and multiple patterns from inner interface #733

@NolwennD

Description

@NolwennD

prettier-plugin-java version: 2.6.7
java version: 24 but will work also above 22

This code leads to errors

public class Fail {

  private Function<ShootResult, ShootResult.Miss> missed() {
    return lastResult -> switch (lastResult) {
      case ShootResult.Miss(int fails) -> new ShootResult.Miss(fails + 1);
      case ShootResult.Many _ ,ShootResult.One _ -> new ShootResult.Miss(0); // crash on this line
             
    };
  }

  private sealed interface ShootResult {
    record One(Pin pin) implements ShootResult {}
    record Many(int number) implements ShootResult {}
    record Miss(int timesInRow) implements ShootResult {}
  }
}

src/main/java/kata/Fail.java: Error: Sad sad panda, parsing errors detected in line: 11, column: 43! [error] Expecting --> '->' <-- but found --> '.' <--!

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