dart-league / dson

dart library which converts Dart Objects into their JSON representation
Apache License 2.0
66 stars 14 forks source link

Extending generic class leads to error #44

Closed ValeriusGC closed 5 years ago

ValeriusGC commented 5 years ago

Hello. I changed sample in extend_serializables to generic to emulate my real case Derived => Base<T>

@serializable
class Person<T> extends _$PersonSerializable<T> {
  int id;
  T firstName;
  String lastName;
  DateTime dateOfBirth;
}

@serializable
// ignore: mixin_inherits_from_not_object
class Employee extends Person<String> with _$EmployeeSerializable {
  double salary;
}

and got an issue:

[SEVERE] dson|dson_builder on example/bin/extend_serializables.dart:
Error formatting generated source code for 102dson/example/bin/extend_serializables.dartwhich was output to example/bin/extend_serializables.g.dart.
This may indicate an issue in the generated code or in the formatter.
Please check the generated code and file an issue on source_gen if appropriate.
Could not format because the source could not be parsed:

line 113, column 369: An equality expression can't be an operand of another equality expression.
    ╷
113 │           },fields: const {'salary': $$Employee_fields_salary,'id': $$Person_fields_id,'firstName': $$Person_fields_firstName,'lastName': $$Person_fields_lastName,'dateOfBirth': $$Person_fields_dateOfBirth},getters: const ['salary','id','firstName','lastName','dateOfBirth'],setters: const ['salary','id','firstName','lastName','dateOfBirth'],superclass: Person<String>
    │                                                                                                       
luisvt commented 5 years ago

fixed, please upgrade version of built_mirrors to 0.10.3, maybe you only need to run pub upgrade

ValeriusGC commented 5 years ago

What do you exactly mean? First there is no such built_mirrors 0.10.3 version in pub repository. Second there is no points in DSON documentation about adding this dependency in YAML. So what shall I do?

luisvt commented 5 years ago

ups sorry, my mistake it should be built_mirrors_core.

Don't worry about it, just run pub upgrade or specify the version of dson to version ^0.15.4