Skip to content

Comments are indented before case statements in enhanced switch #876

Description

@sKwil

Placing single-line or block comments before case statements in an enhanced switch causes them to be indented. This seems to be in violation of 4.8.6.1 Block comment style.

Auto-formatted code:

public class T {
  public static void main(String[] args) {
    int a = 1;
    switch (a) {
      case 1 -> System.out.println("1");

        // This is a comment before a case statement
      case 2 -> System.out.println("2");

        /*
         * Block comment before a case stement
         */
      case 3 -> System.out.println("3");

        // Comment before the default statement
      default -> System.out.println("N/A");
    }
  }
}

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions