Skip to content

Commit 9726e92

Browse files
stereotype441Commit Queue
authored andcommitted
[analyzer] Move late final tests into late_final_local_already_assigned_test.dart.
Some of the tests in `assignment_to_final_local_test.dart` were actually testing `late final` locals, so they make more sense in `late_final_local_already_assigned_test.dart`. This paves the way for fixing #60359 (Using a `late final` variable as loop variable for `for`/`in` gives incorrect late errors). Change-Id: I58da6ae6791adb1b124129b30b0d8c62bfa2d519 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417000 Auto-Submit: Paul Berry <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Konstantin Shcheglov <[email protected]>
1 parent 5d78579 commit 9726e92

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

pkg/analyzer/test/src/diagnostics/assignment_to_final_local_test.dart

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ f() {
2626
]);
2727
}
2828

29-
test_localVariable_final_forEach() async {
29+
test_localVariable_forEach() async {
3030
await assertErrorsInCode('''
3131
f() {
3232
final i;
@@ -51,29 +51,6 @@ f() {
5151
]);
5252
}
5353

54-
test_localVariable_late() async {
55-
await assertNoErrorsInCode('''
56-
void f() {
57-
late final int a;
58-
a = 1;
59-
a;
60-
}
61-
''');
62-
}
63-
64-
test_localVariable_lateFinal_forEach() async {
65-
await assertErrorsInCode('''
66-
f() {
67-
late final int i;
68-
for (i in [1, 2, 3]) {
69-
print(i);
70-
}
71-
}
72-
''', [
73-
error(CompileTimeErrorCode.LATE_FINAL_LOCAL_ALREADY_ASSIGNED, 33, 1),
74-
]);
75-
}
76-
7754
test_localVariable_plusEq() async {
7855
await assertErrorsInCode('''
7956
f() {

pkg/analyzer/test/src/diagnostics/late_final_local_already_assigned_test.dart

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,29 @@ main() {
5353
]);
5454
}
5555

56+
test_localVariable() async {
57+
await assertNoErrorsInCode('''
58+
void f() {
59+
late final int a;
60+
a = 1;
61+
a;
62+
}
63+
''');
64+
}
65+
66+
test_localVariable_forEach() async {
67+
await assertErrorsInCode('''
68+
f() {
69+
late final int i;
70+
for (i in [1, 2, 3]) {
71+
print(i);
72+
}
73+
}
74+
''', [
75+
error(CompileTimeErrorCode.LATE_FINAL_LOCAL_ALREADY_ASSIGNED, 33, 1),
76+
]);
77+
}
78+
5679
test_postfixExpression_inc() async {
5780
await assertErrorsInCode('''
5881
main() {

0 commit comments

Comments
 (0)