-
Notifications
You must be signed in to change notification settings - Fork 82
Description
The current behavior of recording all const instantiations of an annotated class undermines this workflow. The report generated by record_use contains both
- annotation usages (
@MyAnnotation(...)), and constinstantiations of the same class in regular code.
For use cases where we are only interested in annotations (or rather, the classes or method calls that have the annotations that weren't tree-shaken out), the instantiations in running Dart code are noise.
For the use cases where we are interested in all instances only having the const instances lacks the counter part of the non-const instances constructed by constructor calls. This provides a non-true view of all instances.
Proposed solution
Refine the scope of instance recording to only record const instances that are used as metadata annotations.
We should then also rename it to record-annotations rather than record-const-instances.
Alternative considered
Try to collect all constructor invocations of a certain type, including their const arguments. This is better served as putting a record-use annotation on the constructors to record call sites. However, then you'd miss the const instances, as the the compiler does not track constructor calls for const instances. The workaround is to make the constructors non-const, but that's undesirable. Since the main use case is annotations anyway, let's not try to do this.
@HosseinYousefi This covers your JniGen use case right?
Metadata
Metadata
Assignees
Labels
Type
Projects
Status