Test generator fixes

- Revert previous change to constructor return values; as constructors are supposed to be modeled using Argument[-1] rather than ReturnValue
- Fix generation of ambiguous calls when one of the conflicting methods is overridden
This commit is contained in:
Joe Farebrother
2023-02-17 15:30:06 +00:00
parent d9e5c6c48a
commit a9f1436930
2 changed files with 6 additions and 10 deletions

View File

@@ -228,7 +228,7 @@ class TestCase extends TTestCase {
*/
Type getOutputType() {
if baseOutput = SummaryComponentStack::return()
then result = getReturnType(callable)
then result = callable.getReturnType()
else
exists(int i |
baseOutput = SummaryComponentStack::argument(i) and

View File

@@ -16,11 +16,6 @@ Type getRootSourceDeclaration(Type t) {
else result = t
}
/** Gets the return type of the callable c, or the constructed tpe if it's a constructor */
Type getReturnType(Callable c) {
if c instanceof Constructor then result = c.getDeclaringType() else result = c.getReturnType()
}
/**
* Holds if type `t` does not clash with another type we want to import that has the same base name.
*/
@@ -69,11 +64,12 @@ string getZero(PrimitiveType t) {
* Holds if `c` may require disambiguation from an overload with the same argument count.
*/
predicate mayBeAmbiguous(Callable c) {
exists(Callable other, string package, string type, string name |
c.hasQualifiedName(package, type, name) and
exists(Callable other, Callable override, string package, string type, string name |
override = [c, c.(Method).getASourceOverriddenMethod*()] and
override.hasQualifiedName(package, type, name) and
other.hasQualifiedName(package, type, name) and
other.getNumberOfParameters() = c.getNumberOfParameters() and
other != c
other.getNumberOfParameters() = override.getNumberOfParameters() and
other != override
)
or
c.isVarargs()