Skip to content

Cannot use const ctor on a Class with a generic field - error in checked mode #22431

Closed
@kevmoo

Description

@kevmoo

class Foo {
  final List<int> values;

  const Foo(this.values);
}

const _foo = const Foo(const <int>[1,2,3]);

This fails in checked mode because "const <int>[1,2,3]" has a rarified type of "List<Object>", not "List<int>"

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions