File tree Expand file tree Collapse file tree
lib/src/services/correction/dart
test/src/services/correction/assist Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -384,6 +384,7 @@ class _EnumDescription {
384384
385385 if (constructor.documentationComment != null ) return null ;
386386 if (constructor.metadata.isNotEmpty) return null ;
387+ if (constructor.initializers.isNotEmpty) return null ;
387388
388389 var parameters = constructor.parameters.parameters;
389390 // If there's only one constructor, then there can only be one entry in the
@@ -402,8 +403,11 @@ class _EnumDescription {
402403 var name = primaryConstructor.constructorName? .name.lexeme;
403404 if (name != null && name != 'new' ) return null ;
404405
405- if (primaryConstructor.body? .documentationComment != null ) return null ;
406- if (primaryConstructor.body? .metadata.isNotEmpty ?? false ) return null ;
406+ if (primaryConstructor.body case var body? ) {
407+ if (body.documentationComment != null ) return null ;
408+ if (body.metadata.isNotEmpty) return null ;
409+ if (body.initializers.isNotEmpty) return null ;
410+ }
407411
408412 var parameters = primaryConstructor.formalParameters.parameters;
409413 // If there's only one constructor, then there can only be one entry in the
Original file line number Diff line number Diff line change @@ -679,6 +679,23 @@ enum _E {
679679''' );
680680 }
681681
682+ Future <void > test_minimal_privateClass_constructorHasInitializers () async {
683+ await resolveTestCode ('''
684+ class _^E {
685+ static const _E c = _E();
686+
687+ const _E() : assert(1 == 1);
688+ }
689+ ''' );
690+ await assertHasAssist ('''
691+ enum _E {
692+ c;
693+
694+ const _E() : assert(1 == 1);
695+ }
696+ ''' );
697+ }
698+
682699 Future <void > test_minimal_privateClass_primaryConstructor () async {
683700 await resolveTestCode ('''
684701class const _^E() {
@@ -692,6 +709,19 @@ enum _E {
692709''' );
693710 }
694711
712+ Future <void > test_minimal_privateClass_primaryConstructor_generic () async {
713+ await resolveTestCode ('''
714+ class const _^E<T>() {
715+ static const _E c = _E();
716+ }
717+ ''' );
718+ await assertHasAssist ('''
719+ enum _E<T> {
720+ c
721+ }
722+ ''' );
723+ }
724+
695725 Future <void >
696726 test_minimal_privateClass_primaryConstructorHasAnnotation () async {
697727 await resolveTestCode ('''
@@ -795,7 +825,7 @@ enum E {
795825''' );
796826 }
797827
798- Future <void > test_noIndex_notInt_primaryClass () async {
828+ Future <void > test_noIndex_notInt_primaryConstructor () async {
799829 await resolveTestCode ('''
800830class const ^E._(final String name) {
801831 static const E c0 = E._('c0');
You can’t perform that action at this time.
0 commit comments