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

Error when parsing qualified generic type test pattern in switch

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 24
    • 24
    • tools
    • None
    • b27

      The following program does not compile:

      ```
      abstract sealed class J<T1, T2> permits X.S, A {}

      final class A extends J<Integer, String> {}

      public class X<T> {

          final class S<U> extends J<T, U> {}

          int testExhaustive(J<Integer, String> ji) {
              return switch (ji) {
                  case A a -> 42;
                  case X<Integer>.S<String> e -> 4200;
              };
          }
          public static void main(String[] args) {
              X<Integer>.S<String> xs = null;
              System.out.println(new X<Integer>().testExhaustive(new X<Integer>().new S<String>()));
          }
      }
      ```

      See:
      https://mail.openjdk.org/pipermail/compiler-dev/2024-November/028464.html

            abimpoudis Angelos Bimpoudis
            mcimadamore Maurizio Cimadamore
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: