Skip to content

Constant assignments should infer constant constructors #25261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ds84182 opened this issue Dec 15, 2015 · 2 comments
Closed

Constant assignments should infer constant constructors #25261

ds84182 opened this issue Dec 15, 2015 · 2 comments
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report

Comments

@ds84182
Copy link
Contributor

ds84182 commented Dec 15, 2015

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.

@zoechi
Copy link
Contributor

zoechi commented Dec 15, 2015

@lrhn lrhn added the closed-duplicate Closed in favor of an existing report label Dec 16, 2015
@lrhn
Copy link
Member

lrhn commented Dec 16, 2015

The original issue is #4046.
As you might guess, I completely agree that it should be fixed.

@floitschG floitschG added the area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). label Dec 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report
Projects
None yet
Development

No branches or pull requests

4 participants