Skip to content

Commit c11a260

Browse files
committed
Note we can't prove certain unreachable callables when 'case null' is present
1 parent 89f7e7f commit c11a260

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static void test(int unknown, int alsoUnknown) {
2525

2626
switch(i) {
2727
case C1 c1 -> { }
28-
case null, default -> i.take(source()); // Can't call C1.take
28+
case null, default -> i.take(source()); // Can't call C1.take (but we don't currently notice)
2929
}
3030

3131
switch(i) {
@@ -53,6 +53,11 @@ case WrapperWrapper(Wrapper(String s)) -> { }
5353
default -> i.take(source()); // Could call any implementation, because this might be a WrapperWrapper(Wrapper((Integer)) for example.
5454
}
5555

56+
switch(i) {
57+
case C1 c1: break;
58+
case null: default: i.take(source()); // Can't call C1.take (but we don't currently notice)
59+
}
60+
5661
}
5762

5863
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
| Test.java:23:25:23:32 | source(...) | Test.java:8:65:8:65 | x |
66
| Test.java:23:25:23:32 | source(...) | Test.java:9:74:9:74 | x |
77
| Test.java:23:25:23:32 | source(...) | Test.java:10:82:10:82 | x |
8+
| Test.java:28:36:28:43 | source(...) | Test.java:7:65:7:65 | x |
89
| Test.java:28:36:28:43 | source(...) | Test.java:8:65:8:65 | x |
910
| Test.java:28:36:28:43 | source(...) | Test.java:9:74:9:74 | x |
1011
| Test.java:28:36:28:43 | source(...) | Test.java:10:82:10:82 | x |
@@ -25,3 +26,7 @@
2526
| Test.java:53:25:53:32 | source(...) | Test.java:8:65:8:65 | x |
2627
| Test.java:53:25:53:32 | source(...) | Test.java:9:74:9:74 | x |
2728
| Test.java:53:25:53:32 | source(...) | Test.java:10:82:10:82 | x |
29+
| Test.java:58:34:58:41 | source(...) | Test.java:7:65:7:65 | x |
30+
| Test.java:58:34:58:41 | source(...) | Test.java:8:65:8:65 | x |
31+
| Test.java:58:34:58:41 | source(...) | Test.java:9:74:9:74 | x |
32+
| Test.java:58:34:58:41 | source(...) | Test.java:10:82:10:82 | x |

0 commit comments

Comments
 (0)