native
native copied to clipboard
[record_use] Correctness: Record dynamic invocations
Currently, the recording mechanism only captures statically-resolved calls (StaticInvocation) and tear-offs (StaticTearOffConstant). It does not record truly dynamic calls, such as foo.bar() where foo is a dynamic variable.
We should record these dynamic invocations. When the compiler encounters a dynamic call to a method name that matches one or more methods annotated with @RecordUse, it should generate a usage record.
Such a record would be similar to a tear-off, as no argument information can be captured. It could be represented by a new CallReference type:
{
"@": 2,
"type": "dynamic_invocation",
"name": "bar" // The name of the method called dynamically
}
This would provide developers with insight into whether an annotated method might be invoked dynamically, even if the precise call site and arguments cannot be known.