Skip to content

Dart2js errors out when it encounters const Map<Type, AnyThing> #28337

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
tejainece opened this issue Jan 11, 2017 · 1 comment
Closed

Dart2js errors out when it encounters const Map<Type, AnyThing> #28337

tejainece opened this issue Jan 11, 2017 · 1 comment
Labels
closed-duplicate Closed in favor of an existing report web-dart2js

Comments

@tejainece
Copy link

tejainece commented Jan 11, 2017

When Dart2Js encounters const Map<Type, AnyThing>, it throws the following error:

[Error from Dart2JS on web/panel/main.dart]: packages/....dart:14:21: Const-map key type 'TypeImpl' overrides 'operator =='. @ProvideSerializers(const <Type, Type>{ Establishment: EstablishmentSerializer, Speciality: SpecialitySerializer })

Analyzer doesn't have a problem with it. DartVM executes the code pretty fine. source_gen and analyzer package seems to handle them pretty well.

@sigmundch
Copy link
Member

Thanks for reporting this bug, we have run into this in the past but apparently we haven't resolved it. I agree they should be allowed. I'll close this entry to mark it as a duplicate of #17207.

Meanwhile, there is something you can try to work around this limitation. I believe you can define a const class like:

const TypeWrapper {
  final Type type;
  const TypeWrapper(this.type);
}

and use that in a key of a const-map.

Cheers!

@sigmundch sigmundch added the closed-duplicate Closed in favor of an existing report label Jan 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-duplicate Closed in favor of an existing report web-dart2js
Projects
None yet
Development

No branches or pull requests

3 participants