Skip to content

Commit bed37c4

Browse files
committed
Adding test.
1 parent 8735a3d commit bed37c4

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

test/langtools/tools/javac/patterns/Exhaustiveness.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2221,6 +2221,37 @@ record Root(Base b1, Base b2, Base b3) {}
22212221
""");
22222222
}
22232223

2224+
@Test //JDK-8364991
2225+
public void testDifferentReductionPathsSimplified(Path base) throws Exception {
2226+
doTest(base,
2227+
new String[0],
2228+
"""
2229+
package test;
2230+
public class Test {
2231+
private int test1(Root r) {
2232+
return switch (r) {
2233+
case Root(R2(R1 _), R2(R1 _)) -> 0;
2234+
case Root(R2(R1 _), R2(R2 _)) -> 0;
2235+
case Root(R2(R2 _), R2(R1 _)) -> 0;
2236+
case Root(R2(R2 _), R2 _) -> 0;
2237+
};
2238+
}
2239+
private int test2(Root r) {
2240+
return switch (r) {
2241+
case Root(R2(R1 _), R2(R1 _)) -> 0;
2242+
case Root(R2(R2 _), R2(R1 _)) -> 0;
2243+
case Root(R2(R1 _), R2(R2 _)) -> 0;
2244+
case Root(R2 _, R2(R2 _)) -> 0;
2245+
};
2246+
}
2247+
sealed interface Base {}
2248+
record R1() implements Base {}
2249+
record R2(Base b1) implements Base {}
2250+
record Root(R2 b2, R2 b3) {}
2251+
}
2252+
""");
2253+
}
2254+
22242255
@Test //JDK-8364991
22252256
public void testBindingPatternDoesNotStandInPlaceOfRecordPatterns(Path base) throws Exception {
22262257
doTest(base,

0 commit comments

Comments
 (0)