Skip to content

[flutter_tools] const_finder will generate non-const locations for web builds that don't appear in AOT builds #116807

@christopherfujino

Description

@christopherfujino

For the following Dart class "FooBar":

class FooBar {
  const FooBar();
}

The following kernel structure is generated:

class FooBar extends core::Object /*hasConstConstructor*/  {
  const constructor •() → min::FooBar
    : super core::Object::•()
    ;
  static method _#new#tearOff() → min::FooBar
    return new min::FooBar::•(); /* this is a non-const constructor invocation */
  method noOp() → void {}
}

Therefore every class will have an auto-generated static method that invokes it's unnamed constructor in a non-const context. This doesn't affect the const_finder for AOT builds, since TFA will eliminate these static methods (unless a tear-off is actually used). However, for web dills, these will still be present.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority issues at the top of the work listtoolAffects the "flutter" command-line tool. See also t: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions