Add tests for case statement type test dominance against anonymous labels and fall-through

This commit is contained in:
Chris Smowton
2024-03-22 21:18:13 +00:00
parent f2ff6c476a
commit 1e0766dffa
3 changed files with 32 additions and 1 deletions

View File

@@ -58,6 +58,23 @@ public class Test {
case null: default: i.take(source()); // Can't call C1.take (but we don't currently notice)
}
switch(i) {
case C1 _, C2 _:
i.take(source()); // Must be either C1.take or C2.take (but we don't currently notice, because neither dominates)
break;
default:
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)
}
switch(i) {
case C1 _:
case C2 _:
i.take(source()); // Must be either C1.take or C2.take (but we don't currently notice, because neither dominates)
break;
default:
i.take(source()); // Can't call C1.take or C2.take
}
}
}

View File

@@ -1 +1 @@
//semmle-extractor-options: --javac-args --release 21
//semmle-extractor-options: --javac-args --release 22

View File

@@ -30,3 +30,17 @@
| Test.java:58:34:58:41 | source(...) | Test.java:8:65:8:65 | x |
| Test.java:58:34:58:41 | source(...) | Test.java:9:74:9:74 | x |
| Test.java:58:34:58:41 | source(...) | Test.java:10:82:10:82 | x |
| Test.java:63:16:63:23 | source(...) | Test.java:7:65:7:65 | x |
| Test.java:63:16:63:23 | source(...) | Test.java:8:65:8:65 | x |
| Test.java:63:16:63:23 | source(...) | Test.java:9:74:9:74 | x |
| Test.java:63:16:63:23 | source(...) | Test.java:10:82:10:82 | x |
| Test.java:66:16:66:23 | source(...) | Test.java:7:65:7:65 | x |
| Test.java:66:16:66:23 | source(...) | Test.java:8:65:8:65 | x |
| Test.java:66:16:66:23 | source(...) | Test.java:9:74:9:74 | x |
| Test.java:66:16:66:23 | source(...) | Test.java:10:82:10:82 | x |
| Test.java:72:16:72:23 | source(...) | Test.java:7:65:7:65 | x |
| Test.java:72:16:72:23 | source(...) | Test.java:8:65:8:65 | x |
| Test.java:72:16:72:23 | source(...) | Test.java:9:74:9:74 | x |
| Test.java:72:16:72:23 | source(...) | Test.java:10:82:10:82 | x |
| Test.java:75:16:75:23 | source(...) | Test.java:9:74:9:74 | x |
| Test.java:75:16:75:23 | source(...) | Test.java:10:82:10:82 | x |