Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions java/ql/test/library-tests/errortype/Dispatch.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
| Test.java:16:5:16:15 | method(...) | Test.java:11:17:11:22 | method |
6 changes: 6 additions & 0 deletions java/ql/test/library-tests/errortype/Dispatch.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import java
import semmle.code.java.dispatch.VirtualDispatch

from MethodCall mc, Method m
where viableImpl(mc) = m
select mc, m
10 changes: 10 additions & 0 deletions java/ql/test/library-tests/errortype/Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ public NoSuchClass test() {
return nsc;
}

static class GenericClass<T> {
public void method() { }
}

public testDispatch() {
GenericClass<String> g1 = new GenericClass<>();
g1.method();
GenericClass<NoSuchClass> g2 = new GenericClass<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, the QL-based type inference/method resolution implementation should be able to handle cases like these.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's good to know.

g2.method();
}
}

// Diagnostic Matches: Unexpected symbol for constructor: new NoSuchClass()
Expand Down