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

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 24
    • 24
    • 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

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

              Created:
              Updated:
              Resolved: