Skip to content

CFE is not inferring generic type for const default parameters #32415

Closed
@vsmenon

Description

@vsmenon

DDK asserts on the following. DDC does not. In the constructor of C, the CFE is instantiating B with Null (causing the error). The analyzer with T (which works).

class A<T> {
  const A();
}

class B<T> implements A<T> {
  const B();
}

class C<T> {
  final _a;

  const C([A<T> a = const B()]) : _a = a;
}

void main() {
  var c = new C<String>();
  print(c._a.runtimeType);
  assert(c._a is! A<Null>);
}

The result with DDK is:

B<Null>
Assertion failed: is not true Error

@a-siva is hitting this in package:collection.

@kmillikin

Metadata

Metadata

Assignees

Labels

P1A high priority bug; for example, a single project is unusable or has many test failuresarea-pkgUsed for miscellaneous pkg/ packages not associated with specific area- teams.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions