Incorrect switch in enum not reported properly

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P3
    • 21
    • Affects Version/s: None
    • Component/s: tools
    • None
    • b26

      Consider code like:
      ```
      public class QualEnum {
          private void test(E e) {
              switch (e) {
                  case ea -> {}
                  default -> {}
              }
          }
          static final E ea = E.A;
          enum E {A}
      }
      ```

      This should fail to compile with a proper compile-time error, but it crashes javac:
      ```
      java.lang.AssertionError
      at jdk.compiler/com.sun.tools.javac.util.Assert.error(Assert.java:155)
      at jdk.compiler/com.sun.tools.javac.util.Assert.check(Assert.java:46)
      at jdk.compiler/com.sun.tools.javac.comp.Lower$CompileTimeEnumMapping.caseValue(Lower.java:505)
      at jdk.compiler/com.sun.tools.javac.comp.Lower.visitEnumSwitch(Lower.java:3866)
      ...
      ```

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

              Created:
              Updated:
              Resolved: