From c11a260369abb0a9dde45257ddfb7862afbc8f9c Mon Sep 17 00:00:00 2001 From: Chris Smowton Date: Fri, 17 Nov 2023 11:10:06 +0000 Subject: [PATCH] Note we can't prove certain unreachable callables when 'case null' is present --- .../switch-default-impossible-dispatch/Test.java | 7 ++++++- .../switch-default-impossible-dispatch/test.expected | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/java/ql/test/library-tests/switch-default-impossible-dispatch/Test.java b/java/ql/test/library-tests/switch-default-impossible-dispatch/Test.java index b8b0123fdd4..cf6e67e5847 100644 --- a/java/ql/test/library-tests/switch-default-impossible-dispatch/Test.java +++ b/java/ql/test/library-tests/switch-default-impossible-dispatch/Test.java @@ -25,7 +25,7 @@ public class Test { switch(i) { case C1 c1 -> { } - case null, default -> i.take(source()); // Can't call C1.take + case null, default -> i.take(source()); // Can't call C1.take (but we don't currently notice) } switch(i) { @@ -53,6 +53,11 @@ public class Test { default -> i.take(source()); // Could call any implementation, because this might be a WrapperWrapper(Wrapper((Integer)) for example. } + switch(i) { + case C1 c1: break; + case null: default: i.take(source()); // Can't call C1.take (but we don't currently notice) + } + } } diff --git a/java/ql/test/library-tests/switch-default-impossible-dispatch/test.expected b/java/ql/test/library-tests/switch-default-impossible-dispatch/test.expected index 8171281ad6c..17d478d4298 100644 --- a/java/ql/test/library-tests/switch-default-impossible-dispatch/test.expected +++ b/java/ql/test/library-tests/switch-default-impossible-dispatch/test.expected @@ -5,6 +5,7 @@ | Test.java:23:25:23:32 | source(...) | Test.java:8:65:8:65 | x | | Test.java:23:25:23:32 | source(...) | Test.java:9:74:9:74 | x | | Test.java:23:25:23:32 | source(...) | Test.java:10:82:10:82 | x | +| Test.java:28:36:28:43 | source(...) | Test.java:7:65:7:65 | x | | Test.java:28:36:28:43 | source(...) | Test.java:8:65:8:65 | x | | Test.java:28:36:28:43 | source(...) | Test.java:9:74:9:74 | x | | Test.java:28:36:28:43 | source(...) | Test.java:10:82:10:82 | x | @@ -25,3 +26,7 @@ | Test.java:53:25:53:32 | source(...) | Test.java:8:65:8:65 | x | | Test.java:53:25:53:32 | source(...) | Test.java:9:74:9:74 | x | | Test.java:53:25:53:32 | source(...) | Test.java:10:82:10:82 | x | +| Test.java:58:34:58:41 | source(...) | Test.java:7:65:7:65 | x | +| 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 |