Skip to content

[record_use] Completeness: const constructors static "calls" #2911

@dcharkes

Description

@dcharkes
  1. The early compiler phase we might still see it as a constructor call, but then we haven't done any dead code elimination and other optimizations.
  2. Then it is immediately converted to a const instance in the constant pool and the constructor call in the source code is replaced with a reference to that const instance. The information of which constructor was used is lost.

So in order to support such logic, we would need to annotate the const-reference in the ast with what constructor was called. And then if such consts are propagated and used in other consts "migrate" such annotation to the new use sites so that once all optimizations are done we can still get a clear picture of which constructors were "called". This would be a significant undertaking to implement in the VM, dart2js and dart2wasm. (Hence why I filed this issue to stop recording const instances in executable Dart code and only allow const instances in annotation positions where there is 0 ambiguity whether it's a static call or a const instance.)

Originally posted by @dcharkes in #2907

Implementing non-const constructor calls is tracked in:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions