Skip to content

Commit 1fb2735

Browse files
Merge pull request github#12242 from joefarebrother/testgen-improvements
Java: Test generator fixes
2 parents 774030a + a9f1436 commit 1fb2735

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

java/ql/src/utils/flowtestcasegenerator/FlowTestCase.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ class TestCase extends TTestCase {
228228
*/
229229
Type getOutputType() {
230230
if baseOutput = SummaryComponentStack::return()
231-
then result = getReturnType(callable)
231+
then result = callable.getReturnType()
232232
else
233233
exists(int i |
234234
baseOutput = SummaryComponentStack::argument(i) and

java/ql/src/utils/flowtestcasegenerator/FlowTestCaseUtils.qll

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ Type getRootSourceDeclaration(Type t) {
1616
else result = t
1717
}
1818

19-
/** Gets the return type of the callable c, or the constructed tpe if it's a constructor */
20-
Type getReturnType(Callable c) {
21-
if c instanceof Constructor then result = c.getDeclaringType() else result = c.getReturnType()
22-
}
23-
2419
/**
2520
* Holds if type `t` does not clash with another type we want to import that has the same base name.
2621
*/
@@ -69,11 +64,12 @@ string getZero(PrimitiveType t) {
6964
* Holds if `c` may require disambiguation from an overload with the same argument count.
7065
*/
7166
predicate mayBeAmbiguous(Callable c) {
72-
exists(Callable other, string package, string type, string name |
73-
c.hasQualifiedName(package, type, name) and
67+
exists(Callable other, Callable override, string package, string type, string name |
68+
override = [c, c.(Method).getASourceOverriddenMethod*()] and
69+
override.hasQualifiedName(package, type, name) and
7470
other.hasQualifiedName(package, type, name) and
75-
other.getNumberOfParameters() = c.getNumberOfParameters() and
76-
other != c
71+
other.getNumberOfParameters() = override.getNumberOfParameters() and
72+
other != override
7773
)
7874
or
7975
c.isVarargs()

0 commit comments

Comments
 (0)