1+ /*
2+ * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation.
8+ *
9+ * This code is distributed in the hope that it will be useful, but WITHOUT
10+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+ * version 2 for more details (a copy is included in the LICENSE file that
13+ * accompanied this code).
14+ *
15+ * You should have received a copy of the GNU General Public License version
16+ * 2 along with this work; if not, write to the Free Software Foundation,
17+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+ *
19+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+ * or visit www.oracle.com if you need additional information or have any
21+ * questions.
22+ */
23+ /**
24+ * @test
25+ * @bug 8343932
26+ * @summary Error when parsing qualified generic type test pattern in switch
27+ * @compile T8343932.java
28+ */
29+ public class T8343932 {
30+ abstract sealed class J <T1 , T2 > permits X .S , A {}
31+ final class A extends J <Integer , Integer > {}
32+
33+ public class X <T > {
34+ final class S <U > extends J <T , U > {
35+ abstract sealed class J <T1 , T2 > permits XX .SS , AA {}
36+ final class AA extends J <Integer , Integer > {}
37+
38+ public class XX <T > {
39+ final class SS <U > extends J <T , U > {}
40+ }
41+ }
42+
43+ static int test (J <Integer , Integer > ji ) {
44+ return switch (ji ) {
45+ case A a -> 42 ;
46+ case X <Integer >.S <Integer > e -> 4200 ; // level 1
47+ };
48+ }
49+
50+ static int test (X <Integer >.S <Integer >.J <Integer , Integer > ji ) {
51+ return switch (ji ) {
52+ case X <Integer >.S <Integer >.AA a -> 42 ;
53+ case X <Integer >.S <Integer >.XX <Integer >.SS <Integer > e -> 4200 ; // level 2
54+ };
55+ }
56+ }
57+ }
0 commit comments