Add STATIC_BASE_TYPE property to calls #1830
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In several languages (at least PHP, C++, and Java), static methods are inherited as well as instance methods, e.g.
In this example, the
methodFullName
of thefoo
call will beBar.foo:int(int)
while the fullName of the method actually being called isFoo.foo:int(int)
. This call then isn't linked correctly since we assume for static calls the fullName of the call and method are the same.This issue can be fixed during AST creation if we have the type information available (probably Java, probably not C++ and definitely not PHP). To fix this in general, we need to know the base type on which the method is being called so that we can search the ancestor types for the method declaration if necessary, so this PR adds the
STATIC_BASE_TYPE
field to keep track of this information. Before call linking, we can use this information to look up the corresponding type decl which would give us the information we need. The callMETHOD_FULL_NAME
can then be overwritten when we know the correct name.The
STATIC_BASE_TYPE
property name is just an idea and I'm open to changing it if someone has a better one :)Other ideas @ml86 and I discussed for how to represent this were:
RECEIVER
edge to aTYPE_REF
for relevant static calls. The issue is thatTYPE_REFs
are a starting point for some dataflow steps, so without special handling this could impact performance.