google / google-java-format

Reformats Java source code to comply with Google Java Style.
Other
5.49k stars 848 forks source link

Can't format record patterns in switch #1109

Open theqp opened 1 month ago

theqp commented 1 month ago

The formatter can't format the following code, it fails with parsing error.

switch (option) {
  case Some(var a) -> a;
  case None() -> "None";
};
pertyjons commented 1 month ago

Seems not to support Java 22 new features unamed patterns, like this from the examples in JEP 456 https://openjdk.org/jeps/456

  static int count(Iterable<Order> orders) {
    int total = 0;
    for (Order _ : orders)    // Unnamed variable
      total++;
    return total;
  }