Enhanced switch statements have an implicit default which does not complete normally

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P3
    • 20
    • Affects Version/s: 19
    • Component/s: tools
    • None
    • b21

      From:
      https://mail.openjdk.org/pipermail/amber-dev/2022-September/007508.html

      This should compile:
      ---

      public class Example {
        sealed interface Action {
          record PrintAction() implements Action {}
          record DeleteAction() implements Action {}
        }


        public int foo(Action action) {
          switch (action) {
            case Action.PrintAction printAction -> {
              return 1;
            }
            case Action.DeleteAction deleteAction -> {
              return 2;
            }
          }
        }
      }
      ---

            Assignee:
            Jan Lahoda
            Reporter:
            Jan Lahoda
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: