This repository was archived by the owner on Feb 25, 2025. It is now read-only.
File tree 3 files changed +42
-2
lines changed
lib/src/services/correction
test/src/services/correction/fix
3 files changed +42
-2
lines changed Original file line number Diff line number Diff line change @@ -791,8 +791,8 @@ CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE_FROM_DEFERRED_LIBRARY:
791
791
CompileTimeErrorCode.NON_CONSTANT_SET_ELEMENT :
792
792
status : needsEvaluation
793
793
CompileTimeErrorCode.NON_FINAL_FIELD_IN_ENUM :
794
- status : needsFix
795
- notes : Use MakeFinal.new
794
+ status : hasFix
795
+ since : 2.17
796
796
CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR :
797
797
status : needsEvaluation
798
798
CompileTimeErrorCode.NON_GENERATIVE_IMPLICIT_CONSTRUCTOR :
Original file line number Diff line number Diff line change @@ -1082,6 +1082,9 @@ class FixProcessor extends BaseProcessor {
1082
1082
CompileTimeErrorCode .NON_CONST_GENERATIVE_ENUM_CONSTRUCTOR : [
1083
1083
AddConst .new ,
1084
1084
],
1085
+ CompileTimeErrorCode .NON_FINAL_FIELD_IN_ENUM : [
1086
+ MakeFinal .new ,
1087
+ ],
1085
1088
CompileTimeErrorCode .NON_TYPE_AS_TYPE_ARGUMENT : [
1086
1089
CreateClass .new ,
1087
1090
CreateMixin .new ,
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import 'fix_processor.dart';
11
11
12
12
void main () {
13
13
defineReflectiveSuite (() {
14
+ defineReflectiveTests (NonFinalFieldInEnumTest );
14
15
defineReflectiveTests (PreferFinalFieldsBulkTest );
15
16
defineReflectiveTests (PreferFinalFieldsTest );
16
17
defineReflectiveTests (PreferFinalFieldsWithNullSafetyTest );
@@ -21,6 +22,42 @@ void main() {
21
22
});
22
23
}
23
24
25
+ @reflectiveTest
26
+ class NonFinalFieldInEnumTest extends FixProcessorTest {
27
+ @override
28
+ FixKind get kind => DartFixKind .MAKE_FINAL ;
29
+
30
+ Future <void > test_field_type () async {
31
+ await resolveTestCode ('''
32
+ enum E {
33
+ one, two;
34
+ int f = 2;
35
+ }
36
+ ''' );
37
+ await assertHasFix ('''
38
+ enum E {
39
+ one, two;
40
+ final int f = 2;
41
+ }
42
+ ''' );
43
+ }
44
+
45
+ Future <void > test_field_var () async {
46
+ await resolveTestCode ('''
47
+ enum E {
48
+ one, two;
49
+ var f = 2;
50
+ }
51
+ ''' );
52
+ await assertHasFix ('''
53
+ enum E {
54
+ one, two;
55
+ final f = 2;
56
+ }
57
+ ''' );
58
+ }
59
+ }
60
+
24
61
@reflectiveTest
25
62
class PreferFinalFieldsBulkTest extends BulkFixProcessorTest {
26
63
@override
You can’t perform that action at this time.
0 commit comments