Skip to content

[CFE] Incremental compilation for factory constructor call differs from non-incremental #41976

@annagrin

Description

@annagrin

Example (library foo.dart):

abstract class Key {
  const factory Key(String value) = ValueKey;
  const Key.empty();
}

abstract class LocalKey extends Key {
  const LocalKey() : super.empty();
}

class ValueKey implements LocalKey {
  const ValueKey(this.value);
  final String value;
}

void main() {
   var k = Key('t');
   /* breakpoint here */
  print('$k');
}

Initial compilation

of expression Key('t') generates following kernel:

new #lib1::ValueKey::•("t")

Incremental compilation

#lib1::Key::•("t")

This causes DDC to create incorrect JS that evaluates to null at runtime:

foo.Key.new("t")

Repro

See skipped tests in pkg/frontend_server/lib/src/expression_compiler.dart in
https://dart-review.googlesource.com/c/sdk/+/148468

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions