Skip to content

Commit 7976bea

Browse files
stereotype441commit-bot@chromium.org
authored andcommitted
Add ? suffixes to flow analysis tests.
The new flow analysis will only function for libraries that are opted into NNBD, therefore if we want to test that a variable is properly promoted from a nullable type to a non-nullable one, we need its declared type to be explicitly marked as nullable. Change-Id: Ia649167f8069c37b3907ba63cabf4f50224dbade Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/109745 Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Paul Berry <[email protected]>
1 parent 507f404 commit 7976bea

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

pkg/analyzer/test/src/dart/resolution/flow_analysis_test.dart

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class NullableFlowTest extends FlowTestBase {
5151

5252
test_assign_toNonNull() async {
5353
await trackCode(r'''
54-
void f(int x) {
54+
void f(int? x) {
5555
if (x != null) return;
5656
/*nullable*/ x;
5757
x = 0;
@@ -62,7 +62,7 @@ void f(int x) {
6262

6363
test_assign_toNull() async {
6464
await trackCode(r'''
65-
void f(int x) {
65+
void f(int? x) {
6666
if (x == null) return;
6767
/*nonNullable*/ x;
6868
x = null;
@@ -73,7 +73,7 @@ void f(int x) {
7373

7474
test_assign_toUnknown_fromNotNull() async {
7575
await trackCode(r'''
76-
void f(int a, int b) {
76+
void f(int? a, int? b) {
7777
if (a == null) return;
7878
/*nonNullable*/ a;
7979
a = b;
@@ -84,7 +84,7 @@ void f(int a, int b) {
8484

8585
test_assign_toUnknown_fromNull() async {
8686
await trackCode(r'''
87-
void f(int a, int b) {
87+
void f(int? a, int? b) {
8888
if (a != null) return;
8989
/*nullable*/ a;
9090
a = b;
@@ -95,15 +95,15 @@ void f(int a, int b) {
9595

9696
test_binaryExpression_logicalAnd() async {
9797
await trackCode(r'''
98-
void f(int x) {
98+
void f(int? x) {
9999
x == null && /*nullable*/ x.isEven;
100100
}
101101
''');
102102
}
103103

104104
test_binaryExpression_logicalOr() async {
105105
await trackCode(r'''
106-
void f(int x) {
106+
void f(int? x) {
107107
x == null || /*nonNullable*/ x.isEven;
108108
}
109109
''');
@@ -112,7 +112,7 @@ void f(int x) {
112112
test_constructor_if_then_else() async {
113113
await trackCode(r'''
114114
class C {
115-
C(int x) {
115+
C(int? x) {
116116
if (x == null) {
117117
/*nullable*/ x;
118118
} else {
@@ -125,7 +125,7 @@ class C {
125125

126126
test_if_joinThenElse_ifNull() async {
127127
await trackCode(r'''
128-
void f(int a, int b) {
128+
void f(int? a, int? b) {
129129
if (a == null) {
130130
/*nullable*/ a;
131131
if (b == null) return;
@@ -143,7 +143,7 @@ void f(int a, int b) {
143143

144144
test_if_notNull_thenExit_left() async {
145145
await trackCode(r'''
146-
void f(int x) {
146+
void f(int? x) {
147147
if (null != x) return;
148148
/*nullable*/ x;
149149
}
@@ -152,7 +152,7 @@ void f(int x) {
152152

153153
test_if_notNull_thenExit_right() async {
154154
await trackCode(r'''
155-
void f(int x) {
155+
void f(int? x) {
156156
if (x != null) return;
157157
/*nullable*/ x;
158158
}
@@ -161,7 +161,7 @@ void f(int x) {
161161

162162
test_if_null_thenExit_left() async {
163163
await trackCode(r'''
164-
void f(int x) {
164+
void f(int? x) {
165165
if (null == x) return;
166166
/*nonNullable*/ x;
167167
}
@@ -170,7 +170,7 @@ void f(int x) {
170170

171171
test_if_null_thenExit_right() async {
172172
await trackCode(r'''
173-
void f(int x) {
173+
void f(int? x) {
174174
if (x == null) return;
175175
/*nonNullable*/ x;
176176
}
@@ -179,7 +179,7 @@ void f(int x) {
179179

180180
test_if_then_else() async {
181181
await trackCode(r'''
182-
void f(int x) {
182+
void f(int? x) {
183183
if (x == null) {
184184
/*nullable*/ x;
185185
} else {
@@ -192,7 +192,7 @@ void f(int x) {
192192
test_method_if_then_else() async {
193193
await trackCode(r'''
194194
class C {
195-
void f(int x) {
195+
void f(int? x) {
196196
if (x == null) {
197197
/*nullable*/ x;
198198
} else {
@@ -205,7 +205,7 @@ class C {
205205

206206
test_potentiallyMutatedInClosure() async {
207207
await trackCode(r'''
208-
f(int a, int b) {
208+
f(int? a, int? b) {
209209
localFunction() {
210210
a = b;
211211
}
@@ -221,7 +221,7 @@ f(int a, int b) {
221221

222222
test_tryFinally_eqNullExit_body() async {
223223
await trackCode(r'''
224-
void f(int x) {
224+
void f(int? x) {
225225
try {
226226
if (x == null) return;
227227
/*nonNullable*/ x;
@@ -235,7 +235,7 @@ void f(int x) {
235235

236236
test_tryFinally_eqNullExit_finally() async {
237237
await trackCode(r'''
238-
void f(int x) {
238+
void f(int? x) {
239239
try {
240240
x;
241241
} finally {
@@ -249,7 +249,7 @@ void f(int x) {
249249

250250
test_tryFinally_outerEqNotNullExit_assignUnknown_body() async {
251251
await trackCode(r'''
252-
void f(int a, int b) {
252+
void f(int? a, int? b) {
253253
if (a != null) return;
254254
try {
255255
/*nullable*/ a;
@@ -265,7 +265,7 @@ void f(int a, int b) {
265265

266266
test_tryFinally_outerEqNullExit_assignUnknown_body() async {
267267
await trackCode(r'''
268-
void f(int a, int b) {
268+
void f(int? a, int? b) {
269269
if (a == null) return;
270270
try {
271271
/*nonNullable*/ a;
@@ -281,7 +281,7 @@ void f(int a, int b) {
281281

282282
test_tryFinally_outerEqNullExit_assignUnknown_finally() async {
283283
await trackCode(r'''
284-
void f(int a, int b) {
284+
void f(int? a, int? b) {
285285
if (a == null) return;
286286
try {
287287
/*nonNullable*/ a;
@@ -297,7 +297,7 @@ void f(int a, int b) {
297297

298298
test_while_eqNull() async {
299299
await trackCode(r'''
300-
void f(int x) {
300+
void f(int? x) {
301301
while (x == null) {
302302
/*nullable*/ x;
303303
}
@@ -308,7 +308,7 @@ void f(int x) {
308308

309309
test_while_notEqNull() async {
310310
await trackCode(r'''
311-
void f(int x) {
311+
void f(int? x) {
312312
while (x != null) {
313313
/*nonNullable*/ x;
314314
}

0 commit comments

Comments
 (0)