File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
lib/src/services/correction/dart
test/src/services/correction/fix Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,11 @@ class ReplaceFinalWithVar extends ResolvedCorrectionProducer {
4646 keyword: var keywordToken,
4747 )) {
4848 finalKeyword = keywordToken;
49+ } else if (context.node case DeclaredIdentifier (
50+ keyword: var keywordToken? ,
51+ )) {
52+ assert (keywordToken.keyword == Keyword .FINAL );
53+ finalKeyword = keywordToken;
4954 }
5055
5156 return ReplaceFinalWithVar ._(
Original file line number Diff line number Diff line change @@ -50,6 +50,21 @@ class ReplaceFinalWithVarTest extends FixProcessorLintTest {
5050 @override
5151 String get lintCode => LintNames .unnecessary_final;
5252
53+ Future <void > test_function_forLoop () async {
54+ await resolveTestCode ('''
55+ void f(List<int> values) {
56+ // ignore:unused_local_variable
57+ for (final v in values) {}
58+ }
59+ ''' );
60+ await assertHasFix ('''
61+ void f(List<int> values) {
62+ // ignore:unused_local_variable
63+ for (var v in values) {}
64+ }
65+ ''' );
66+ }
67+
5368 Future <void > test_function_variableTyped () async {
5469 await resolveTestCode ('''
5570void f() {
You can’t perform that action at this time.
0 commit comments