Skip to content

Warn if a class with const constructor can actually never be const constructed #58719

@goderbauer

Description

@goderbauer

My understanding from flutter/flutter#102460 (comment) and dart-lang/language#1296 is that the following class can actually never be const constructed.

@immutable
class Foo {
  const Foo(this.list) : assert(list.length > 2);
  final List<int> list;
}

To make this clear, the const should be removed from the constructor. Would it be possible to have a lint for that reminds people to not mark it as const?

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-linterIssues with the analyzer's support for the linter packagelinter-lint-proposaltype-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions