Skip to content
This repository has been archived by the owner on Feb 17, 2023. It is now read-only.

DataFields with a name including 'T' break code generation #39

Closed
WanderingFire2001 opened this issue Feb 5, 2020 · 1 comment · Fixed by #40
Closed

DataFields with a name including 'T' break code generation #39

WanderingFire2001 opened this issue Feb 5, 2020 · 1 comment · Fixed by #40

Comments

@WanderingFire2001
Copy link

Latest update (0.4.0, released several hours ago) has a very bad bug.

Any data field with a capital 'T' in the name appears to break code generation, yielding the standard comment header and the single line:
/*State must be annotated with @generic*/

To reproduce:

The following works properly -- exactly as you would expect:

import 'package:super_enum/super_enum.dart';

part 'super_enum_sample.g.dart';

class SomeVee {
  String data;
}

@superEnum
enum _StatesGood {
  @Data(fields: [
    DataField<SomeVee>('fieldName'),
  ])
  State
}

The following fails, and is the same other than the type of field, now being SomeTee instead of SomeVee (T in the name vs no T in the name).

import 'package:super_enum/super_enum.dart';

part 'super_enum_sample.g.dart';

class SomeTee {
  String data;
}

@superEnum
enum _StatesBad {
  @Data(fields: [
    DataField<SomeTee>('fieldName'),
  ])
  State
}

The problem stems from line 377 of class_generator.dart

    if (_classFields
        .any((e) => type_processor.dataFieldType(e).contains('T'))) {
      if (!isGeneric) {
        throw InvalidGenerationSourceError(
            '${field.name} must be annotated with @generic');
      }
    }

(Hairy debug session to find this... 'my T' was in a complex type using built values and I had a lot of suspicions to track down before I got to "does it include a capital T' ;-)

Love all the new features, thanks for all your hard work!

@astralstriker
Copy link
Collaborator

astralstriker commented Feb 5, 2020

That's a very bad bug indeed. Thanks for letting us know. Will fix this on an urgent basis.
Sorry that you had to go through that rigorous debugging.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants