javac is failing to determine if a class and a sealed interface are disjoint

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P4
    • 24
    • Affects Version/s: 24
    • Component/s: tools
    • None
    • b24

      given:

      public class X1 {
          sealed interface I permits C1 {}
          non-sealed class C1 implements I {}
          class C2 extends C1 {}
          class C3 {}
          I m2(int s, C3 c3) {
              return switch (s) {
                  case 0 -> (I) c3;
                  default -> null;
              };
          }
      }

      javac is failing to determine that C3 and I are disjoint and thus C3 is not castable to I

      reported by Stephan Herrmann:
      https://mail.openjdk.org/pipermail/compiler-dev/2024-October/028344.html

            Assignee:
            Vicente Arturo Romero Zaldivar
            Reporter:
            Vicente Arturo Romero Zaldivar
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: