Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8294670

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

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 20
    • 19
    • tools
    • None
    • b21

    Description

      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;
            }
          }
        }
      }
      ---

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: