Skip to content

Constant assignments should infer constant constructors #25261

Closed
@ds84182

Description

@ds84182

For example, take this "goldfish" constant Item constructor:

static const Item goldfish =
    const Item(Colors.orange, "goldfish", "goldfishes", const [
        const FishableItemTrait(0.8),
        const CrushableItemTrait(const [const CrushChance(Items.gold, 0.7)])
    ]);

In order to actually make this object constant, I had to opt to using const everywhere, instead of letting Dart infer the need for const. This would not become ambiguous in any way as the item itself, the goldfish, is declared constant.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-languageDart language related items (some items might be better tracked at github.com/dart-lang/language).closed-duplicateClosed in favor of an existing report

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions