Skip to content

Augmentation libraries: Augmented constructor initializers appear to be ignored. #55766

Open
@rrousselGit

Description

@rrousselGit

Consider:

@Freezed()
class A {
  A(Map<String, Object?> map);
}

Where the generated code is:

augment class A {
  augment A(
    prefix0.Map<prefix0.String, prefix0.Object?> map, 
  ) : map = {'c': 42}; // Notice how we hard-coded the content

  final prefix0.Map<prefix0.String, prefix0.Object?> map;
}

In theory, print(A({'a': 0}).map should always print {'c': 42}. But somehow, this prints {'a': 0}.

This makes no sense, as the parameter is unused here, and the field initialization is hard-coded.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-dart-modelFor issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.cfe-feature-augmentationImplement augmentation features in the CFEcfe-feature-macrosImplement macros features in the CFEfeature-augmentationsImplementation of the augmentations feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions