diff --git a/java/ql/test/library-tests/errortype/Dispatch.expected b/java/ql/test/library-tests/errortype/Dispatch.expected new file mode 100644 index 000000000000..68990d0c3bba --- /dev/null +++ b/java/ql/test/library-tests/errortype/Dispatch.expected @@ -0,0 +1 @@ +| Test.java:16:5:16:15 | method(...) | Test.java:11:17:11:22 | method | diff --git a/java/ql/test/library-tests/errortype/Dispatch.ql b/java/ql/test/library-tests/errortype/Dispatch.ql new file mode 100644 index 000000000000..2c9af37602c4 --- /dev/null +++ b/java/ql/test/library-tests/errortype/Dispatch.ql @@ -0,0 +1,6 @@ +import java +import semmle.code.java.dispatch.VirtualDispatch + +from MethodCall mc, Method m +where viableImpl(mc) = m +select mc, m diff --git a/java/ql/test/library-tests/errortype/Test.java b/java/ql/test/library-tests/errortype/Test.java index c393faf75990..2999994b3cae 100644 --- a/java/ql/test/library-tests/errortype/Test.java +++ b/java/ql/test/library-tests/errortype/Test.java @@ -7,6 +7,16 @@ public NoSuchClass test() { return nsc; } + static class GenericClass { + public void method() { } + } + + public void testDispatch() { + GenericClass g1 = new GenericClass<>(); + g1.method(); + GenericClass g2 = new GenericClass<>(); + g2.method(); + } } // Diagnostic Matches: Unexpected symbol for constructor: new NoSuchClass()