Skip to content

Commit c48e64e

Browse files
committed
Add tests for the combination of anonymous labels and a guard
1 parent 1e0766d commit c48e64e

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

java/ql/test/library-tests/switch-default-impossible-dispatch/Test.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ case WrapperWrapper(Wrapper(String s)) -> { }
6666
i.take(source()); // Can't call C1.take or C2.take (but we don't currently notice, because a multi-pattern case isn't understood as a type test)
6767
}
6868

69+
switch(i) {
70+
case C1 _, C2 _ when i.toString().equals("abc"):
71+
i.take(source()); // Must be either C1.take or C2.take (but we don't currently notice, because neither dominates)
72+
break;
73+
default:
74+
i.take(source()); // Can't call C1.take or C2.take (but we don't currently notice, because a multi-pattern case isn't understood as a type test)
75+
}
76+
6977
switch(i) {
7078
case C1 _:
7179
case C2 _:

java/ql/test/library-tests/switch-default-impossible-dispatch/test.expected

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,17 @@
3838
| Test.java:66:16:66:23 | source(...) | Test.java:8:65:8:65 | x |
3939
| Test.java:66:16:66:23 | source(...) | Test.java:9:74:9:74 | x |
4040
| Test.java:66:16:66:23 | source(...) | Test.java:10:82:10:82 | x |
41-
| Test.java:72:16:72:23 | source(...) | Test.java:7:65:7:65 | x |
42-
| Test.java:72:16:72:23 | source(...) | Test.java:8:65:8:65 | x |
43-
| Test.java:72:16:72:23 | source(...) | Test.java:9:74:9:74 | x |
44-
| Test.java:72:16:72:23 | source(...) | Test.java:10:82:10:82 | x |
45-
| Test.java:75:16:75:23 | source(...) | Test.java:9:74:9:74 | x |
46-
| Test.java:75:16:75:23 | source(...) | Test.java:10:82:10:82 | x |
41+
| Test.java:71:16:71:23 | source(...) | Test.java:7:65:7:65 | x |
42+
| Test.java:71:16:71:23 | source(...) | Test.java:8:65:8:65 | x |
43+
| Test.java:71:16:71:23 | source(...) | Test.java:9:74:9:74 | x |
44+
| Test.java:71:16:71:23 | source(...) | Test.java:10:82:10:82 | x |
45+
| Test.java:74:16:74:23 | source(...) | Test.java:7:65:7:65 | x |
46+
| Test.java:74:16:74:23 | source(...) | Test.java:8:65:8:65 | x |
47+
| Test.java:74:16:74:23 | source(...) | Test.java:9:74:9:74 | x |
48+
| Test.java:74:16:74:23 | source(...) | Test.java:10:82:10:82 | x |
49+
| Test.java:80:16:80:23 | source(...) | Test.java:7:65:7:65 | x |
50+
| Test.java:80:16:80:23 | source(...) | Test.java:8:65:8:65 | x |
51+
| Test.java:80:16:80:23 | source(...) | Test.java:9:74:9:74 | x |
52+
| Test.java:80:16:80:23 | source(...) | Test.java:10:82:10:82 | x |
53+
| Test.java:83:16:83:23 | source(...) | Test.java:9:74:9:74 | x |
54+
| Test.java:83:16:83:23 | source(...) | Test.java:10:82:10:82 | x |

0 commit comments

Comments
 (0)