Polymorphic call graph
Before implementing
Include polymorphic calls into the call graph. The three kinds of calls are MethodCallExpr
(depends on the scope for its target), ObjectCreationExpr
(target is always clear) and ExplicitConstructorInvocation
(target is always clear).
The only case we're interested in is MethodCallExpr
where the target is not static. In that case, we need to find the possible dynamic types of the scope. If there is no scope, this
is used (static calls have been discarded). The scope can be any expression, such as:
-
this
: the current object can be its static type and any derivative. - Variable or field: we're able to obtain the intra-procedural dynamic type with the resolver.
- Method call: The possible output types, which can be precomputed by examining the
-output-
variable. This requires an improvement to theDynamicTypeResolver
to be able to determine transitive types (Object a = new String(); return a;
, thus the return value must be a String).
After implementing
I haven't used the DynamicTypeResolver
, but its inclusion is relatively easy. For now, the computed types and all their subtypes are used to generate polymorphic calls. A couple of examples have already been improved by doing so.
Caveats
default
methods in interfaces are not supported, there is a TODO
item left in the code.