Skip to content

Analyzer does not eliminate type variables from const values #32918

@leafpetersen

Description

@leafpetersen

This is the analyzer specific issue for the least closure part of #32415 .

The following program prints B<Null> and passes the assertion when run with DDC + kernel, but prints B<String> and fails the assertion under DDC + analyzer. The analyzer should be taking the least closure of the inferred type argument to B to eliminate the type variable (which is not otherwise a valid const type.)

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>);
}

Metadata

Metadata

Assignees

Labels

P2A bug or feature request we're likely to work onanalyzer-constantslegacy-area-analyzerUse area-devexp instead.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions