Skip to content

Commit d127486

Browse files
stereotype441Commit Queue
authored andcommitted
Fix up comments in reachability test data.
Turning on the sound-flow-analysis language feature caused a lot of code to be classified as unreachable. This change updates comments in the reachability tests to reflect the new behavior. Bug: #60438 Change-Id: Iec3fd10e4a5d7f890bbe14e0eadd845eeb7a3225 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427584 Reviewed-by: Johnni Winther <[email protected]> Auto-Submit: Paul Berry <[email protected]> Commit-Queue: Johnni Winther <[email protected]>
1 parent 0fcd1a6 commit d127486

File tree

3 files changed

+45
-70
lines changed

3 files changed

+45
-70
lines changed

pkg/_fe_analyzer_shared/test/flow_analysis/reachability/data/equality_operator.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void nullableValue(int? x) {
3838

3939
void nonNullableValue(int x) {
4040
if (x == null) /*unreachable*/ {
41-
// Reachable since the value of x might come from legacy code
41+
// Unreachable since Dart 3.9.
4242
/*stmt: unreachable*/
4343
1;
4444
} else {
@@ -72,7 +72,7 @@ void potentiallyNullableTypeVar_nullableBound<T extends Object?>(T x) {
7272

7373
void nonNullableTypeVar<T extends Object>(T x) {
7474
if (x == null) /*unreachable*/ {
75-
// Reachable since the value of x might come from legacy code
75+
// Unreachable since Dart 3.9.
7676
/*stmt: unreachable*/
7777
1;
7878
} else {

pkg/_fe_analyzer_shared/test/flow_analysis/reachability/data/if_null.dart

Lines changed: 33 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ void variable_if_null_assign_reachable(int? i) {
1111
}
1212

1313
void variable_if_null_unreachable(int i) {
14-
// Reachable since the value of i might come from legacy code
14+
// Unreachable since Dart 3.9.
1515
i ?? /*unreachable*/ 0;
1616
}
1717

1818
void variable_if_null_assign_unreachable(int i) {
19-
// Reachable since the value of i might come from legacy code
19+
// Unreachable since Dart 3.9.
2020
/*cfe.update: unreachable*/
2121
i ??= /*unreachable*/ 0;
2222
}
2323

2424
void variable_if_null_assign_unreachable_due_to_promotion(int? i) {
2525
if (i == null) return;
26-
// Reachable since the value of i might come from legacy code
26+
// Unreachable since Dart 3.9.
2727
/*cfe.update: unreachable*/
2828
i ??= /*unreachable*/ 0;
2929
}
@@ -45,14 +45,12 @@ void top_level_if_null_assign_reachable() {
4545
}
4646

4747
void top_level_if_null_unreachable() {
48-
// Reachable since the value returned by topLevelNonNullGet might come from
49-
// legacy code
48+
// Unreachable since Dart 3.9.
5049
topLevelNonNullGet ?? /*unreachable*/ 0;
5150
}
5251

5352
void top_level_if_null_assign_unreachable() {
54-
// Reachable since the value returned by topLevelNonNullGet might come from
55-
// legacy code
53+
// Unreachable since Dart 3.9.
5654
topLevelNonNullGet /*cfe.update: unreachable*/ ??= /*unreachable*/ 0;
5755
}
5856

@@ -71,12 +69,12 @@ void property_if_null_assign_reachable(HasProperty<int?> x) {
7169
}
7270

7371
void property_if_null_unreachable(HasProperty<int> x) {
74-
// Reachable since the value returned by prop might come from legacy code
72+
// Unreachable since Dart 3.9.
7573
x.prop ?? /*unreachable*/ 0;
7674
}
7775

7876
void property_if_null_assign_unreachable(HasProperty<int> x) {
79-
// Reachable since the value returned by prop might come from legacy code
77+
// Unreachable since Dart 3.9.
8078
x.prop ??= /*unreachable*/ 0;
8179
}
8280

@@ -89,13 +87,12 @@ void null_aware_property_if_null_assign_reachable(HasProperty<int?>? x) {
8987
}
9088

9189
void null_aware_property_if_null_not_shortened(HasProperty<int>? x) {
92-
// Reachable since the value returned by prop might come from legacy code.
93-
// Also since `??` doesn't participate in null shortening.
90+
// Reachable since `??` doesn't participate in null shortening.
9491
x?.prop ?? 0;
9592
}
9693

9794
void null_aware_property_if_null_assign_unreachable(HasProperty<int>? x) {
98-
// Reachable since the value returned by prop might come from legacy code.
95+
// Reachable since Dart 3.9.
9996
x?.prop ??= /*unreachable*/ 0;
10097
}
10198

@@ -111,12 +108,12 @@ class SuperIntQuestionProperty extends HasProperty<int?> {
111108

112109
class SuperIntProperty extends HasProperty<int> {
113110
void if_null_unreachable() {
114-
// Reachable since the value returned by prop might come from legacy code.
111+
// Unreachable since Dart 3.9.
115112
super.prop ?? /*unreachable*/ 0;
116113
}
117114

118115
void if_null_assign_unreachable() {
119-
// Reachable since the value returned by prop might come from legacy code.
116+
// Unreachable since Dart 3.9.
120117
super.prop ??= /*unreachable*/ 0;
121118
}
122119
}
@@ -138,14 +135,12 @@ void extended_property_if_null_assign_reachable(HasProperty<int?> x) {
138135
}
139136

140137
void extended_property_if_null_unreachable(HasProperty<int> x) {
141-
// Reachable since the value returned by extendedProp might come from legacy
142-
// code.
138+
// Unreachable since Dart 3.9.
143139
x.extendedProp ?? /*unreachable*/ 0;
144140
}
145141

146142
void extended_property_if_null_assign_unreachable(HasProperty<int> x) {
147-
// Reachable since the value returned by extendedProp might come from legacy
148-
// code.
143+
// Unreachable since Dart 3.9.
149144
x.extendedProp ??= /*unreachable*/ 0;
150145
}
151146

@@ -160,16 +155,14 @@ void null_aware_extended_property_if_null_assign_reachable(
160155
}
161156

162157
void null_aware_extended_property_if_null_not_shortened(HasProperty<int>? x) {
163-
// Reachable since the value returned by extendedProp might come from legacy
164-
// code, and because `??` doesn't participate in null shortening.
158+
// Reachable because `??` doesn't participate in null shortening.
165159
x?.extendedProp ?? 0;
166160
}
167161

168162
void null_aware_extended_property_if_null_assign_unreachable(
169163
HasProperty<int>? x,
170164
) {
171-
// Reachable since the value returned by extendedProp might come from legacy
172-
// code.
165+
// Unreachable since Dart 3.9.
173166
x?.extendedProp ??= /*unreachable*/ 0;
174167
}
175168

@@ -182,14 +175,12 @@ void explicit_extended_property_if_null_assign_reachable(HasProperty<int?> x) {
182175
}
183176

184177
void explicit_extended_property_if_null_unreachable(HasProperty<int> x) {
185-
// Reachable since the value returned by extendedProp might come from legacy
186-
// code.
178+
// Unreachable since Dart 3.9.
187179
ExtensionProperty(x).extendedProp ?? /*unreachable*/ 0;
188180
}
189181

190182
void explicit_extended_property_if_null_assign_unreachable(HasProperty<int> x) {
191-
// Reachable since the value returned by extendedProp might come from legacy
192-
// code.
183+
// Unreachable since Dart 3.9.
193184
ExtensionProperty(x).extendedProp ??= /*unreachable*/ 0;
194185
}
195186

@@ -208,16 +199,14 @@ void null_aware_explicit_extended_property_if_null_assign_reachable(
208199
void null_aware_explicit_extended_property_if_null_not_shortened(
209200
HasProperty<int>? x,
210201
) {
211-
// Reachable since the value returned by extendedProp might come from legacy
212-
// code, and because `??` doesn't participate in null shortening.
202+
// Reachable because `??` doesn't participate in null shortening.
213203
ExtensionProperty(x)?.extendedProp ?? 0;
214204
}
215205

216206
void null_aware_explicit_extended_property_if_null_assign_unreachable(
217207
HasProperty<int>? x,
218208
) {
219-
// Reachable since the value returned by extendedProp might come from legacy
220-
// code.
209+
// Unreachable since Dart 3.9.
221210
ExtensionProperty(x)?.extendedProp ??= /*unreachable*/ 0;
222211
}
223212

@@ -232,8 +221,7 @@ void index_if_null_reachable(Indexable<int?> x) {
232221
}
233222

234223
void index_if_null_unreachable(Indexable<int> x) {
235-
// Reachable since the value returned by operator[] might come from legacy
236-
// code.
224+
// Unreachable since Dart 3.9.
237225
x[0] ?? /*unreachable*/ 0;
238226
}
239227

@@ -242,8 +230,7 @@ void index_if_null_assign_reachable(Indexable<int?> x) {
242230
}
243231

244232
void index_if_null_assign_unreachable(Indexable<int> x) {
245-
// Reachable since the value returned by operator[] might come from legacy
246-
// code.
233+
// Unreachable since Dart 3.9.
247234
x[0] ??= /*unreachable*/ 0;
248235
}
249236

@@ -252,8 +239,7 @@ void null_aware_index_if_null_reachable(Indexable<int?>? x) {
252239
}
253240

254241
void null_aware_index_if_null_unreachable(Indexable<int>? x) {
255-
// Reachable since the value returned by operator[] might come from legacy
256-
// code, and because `??` doesn't participate in null shortening.
242+
// Reachable because `??` doesn't participate in null shortening.
257243
x?[0] ?? 0;
258244
}
259245

@@ -262,8 +248,7 @@ void null_aware_index_if_null_assign_reachable(Indexable<int?>? x) {
262248
}
263249

264250
void null_aware_index_if_null_assign_unreachable(Indexable<int>? x) {
265-
// Reachable since the value returned by operator[] might come from legacy
266-
// code.
251+
// Unreachable since Dart 3.9.
267252
x?[0] ??= /*unreachable*/ 0;
268253
}
269254

@@ -279,14 +264,12 @@ class SuperIntQuestionIndex extends Indexable<int?> {
279264

280265
class SuperIntIndex extends Indexable<int> {
281266
void if_null_unreachable() {
282-
// Reachable since the value returned by operator[] might come from legacy
283-
// code.
267+
// Unreachable since Dart 3.9.
284268
super[0] ?? /*unreachable*/ 0;
285269
}
286270

287271
void if_null_assign_unreachable() {
288-
// Reachable since the value returned by operator[] might come from legacy
289-
// code.
272+
// Unreachable since Dart 3.9.
290273
super[0] ??= /*unreachable*/ 0;
291274
}
292275
}
@@ -308,14 +291,12 @@ void extended_index_if_null_assign_reachable(HasProperty<int?> x) {
308291
}
309292

310293
void extended_index_if_null_unreachable(HasProperty<int> x) {
311-
// Reachable since the value returned by operator[] might come from legacy
312-
// code.
294+
// Unreachable since Dart 3.9.
313295
x[0] ?? /*unreachable*/ 0;
314296
}
315297

316298
void extended_index_if_null_assign_unreachable(HasProperty<int> x) {
317-
// Reachable since the value returned by operator[] might come from legacy
318-
// code.
299+
// Unreachable since Dart 3.9.
319300
x[0] ??= /*unreachable*/ 0;
320301
}
321302

@@ -328,14 +309,12 @@ void null_aware_extended_index_if_null_assign_reachable(HasProperty<int?>? x) {
328309
}
329310

330311
void null_aware_extended_index_if_null_not_shortened(HasProperty<int>? x) {
331-
// Reachable since the value returned by operator[] might come from legacy
332-
// code, and because `??` doesn't participate in null shortening.
312+
// Reachable because `??` doesn't participate in null shortening.
333313
x?[0] ?? 0;
334314
}
335315

336316
void null_aware_extended_index_if_null_assign_unreachable(HasProperty<int>? x) {
337-
// Reachable since the value returned by operator[] might come from legacy
338-
// code.
317+
// Unreachable since Dart 3.9.
339318
x?[0] ??= /*unreachable*/ 0;
340319
}
341320

@@ -348,14 +327,12 @@ void explicit_extended_index_if_null_assign_reachable(HasProperty<int?> x) {
348327
}
349328

350329
void explicit_extended_index_if_null_unreachable(HasProperty<int> x) {
351-
// Reachable since the value returned by operator[] might come from legacy
352-
// code.
330+
// Unreachable since Dart 3.9.
353331
ExtensionIndex(x)[0] ?? /*unreachable*/ 0;
354332
}
355333

356334
void explicit_extended_index_if_null_assign_unreachable(HasProperty<int> x) {
357-
// Reachable since the value returned by operator[] might come from legacy
358-
// code.
335+
// Unreachable since Dart 3.9.
359336
ExtensionIndex(x)[0] ??= /*unreachable*/ 0;
360337
}
361338

@@ -374,15 +351,13 @@ void null_aware_explicit_extended_index_if_null_assign_reachable(
374351
void null_aware_explicit_extended_index_if_null_not_shortened(
375352
HasProperty<int>? x,
376353
) {
377-
// Reachable since the value returned by operator[] might come from legacy
378-
// code, and because `??` doesn't participate in null shortening.
354+
// Reachable because `??` doesn't participate in null shortening.
379355
ExtensionIndex(x)?[0] ?? 0;
380356
}
381357

382358
void null_aware_explicit_extended_index_if_null_assign_unreachable(
383359
HasProperty<int>? x,
384360
) {
385-
// Reachable since the value returned by operator[] might come from legacy
386-
// code.
361+
// Unreachable since Dart 3.9.
387362
ExtensionIndex(x)?[0] ??= /*unreachable*/ 0;
388363
}

pkg/_fe_analyzer_shared/test/flow_analysis/reachability/data/null_aware_access.dart

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ void index_reachable(List<int>? f()) {
99

1010
/*member: index_unreachable:doesNotComplete*/
1111
void index_unreachable(List<int> f()) {
12-
// Reachable since the value returned by f() might come from legacy code
12+
// Unreachable since Dart 3.9.
1313
f()?[throw ''];
1414
/*stmt: unreachable*/
1515
0;
@@ -22,7 +22,7 @@ void cascaded_index_reachable(List<int>? f()) {
2222

2323
/*member: cascaded_index_unreachable:doesNotComplete*/
2424
void cascaded_index_unreachable(List<int> f()) {
25-
// Reachable since the value returned by f() might come from legacy code
25+
// Unreachable since Dart 3.9.
2626
f()?..[throw ''];
2727
/*stmt: unreachable*/
2828
0;
@@ -35,7 +35,7 @@ void method_invocation_reachable(int? f()) {
3535

3636
/*member: method_invocation_unreachable:doesNotComplete*/
3737
void method_invocation_unreachable(int f()) {
38-
// Reachable since the value returned by f() might come from legacy code
38+
// Unreachable since Dart 3.9.
3939
f()?.remainder(throw '');
4040
/*stmt: unreachable*/
4141
0;
@@ -48,7 +48,7 @@ void cascaded_method_invocation_reachable(int? f()) {
4848

4949
/*member: cascaded_method_invocation_unreachable:doesNotComplete*/
5050
void cascaded_method_invocation_unreachable(int f()) {
51-
// Reachable since the value returned by f() might come from legacy code
51+
// Unreachable since Dart 3.9.
5252
f()?..remainder(throw '');
5353
/*stmt: unreachable*/
5454
0;
@@ -61,7 +61,7 @@ void property_get_reachable(int? f()) {
6161

6262
/*member: property_get_unreachable:doesNotComplete*/
6363
void property_get_unreachable(int f()) {
64-
// Reachable since the value returned by f() might come from legacy code
64+
// Unreachable since Dart 3.9.
6565
f()?.hashCode.remainder(throw '');
6666
/*stmt: unreachable*/
6767
0;
@@ -74,7 +74,7 @@ void cascaded_property_get_reachable(int? f()) {
7474

7575
/*member: cascaded_property_get_unreachable:doesNotComplete*/
7676
void cascaded_property_get_unreachable(int f()) {
77-
// Reachable since the value returned by f() might come from legacy code
77+
// Unreachable since Dart 3.9.
7878
f()?..hashCode.remainder(throw '');
7979
/*stmt: unreachable*/
8080
0;
@@ -90,7 +90,7 @@ void property_get_invocation_reachable(List<void Function(dynamic)>? f()) {
9090

9191
/*member: property_get_invocation_unreachable:doesNotComplete*/
9292
void property_get_invocation_unreachable(List<void Function(dynamic)> f()) {
93-
// Reachable since the value returned by f() might come from legacy code
93+
// Unreachable since Dart 3.9.
9494
// We need a special test case for this because it parses like a method
9595
// invocation but the analyzer rewrites it as a property access followed by a
9696
// function expression invocation.
@@ -113,7 +113,7 @@ void cascaded_property_get_invocation_reachable(
113113
void cascaded_property_get_invocation_unreachable(
114114
List<void Function(dynamic)> f(),
115115
) {
116-
// Reachable since the value returned by f() might come from legacy code
116+
// Unreachable since Dart 3.9.
117117
// We need a special test case for this because it parses like a method
118118
// invocation but the analyzer rewrites it as a property access followed by a
119119
// function expression invocation.
@@ -133,7 +133,7 @@ void property_set_reachable(C? f()) {
133133

134134
/*member: property_set_unreachable:doesNotComplete*/
135135
void property_set_unreachable(C f()) {
136-
// Reachable since the value returned by f() might come from legacy code
136+
// Unreachable since Dart 3.9.
137137
f()?.field = throw '';
138138
/*stmt: unreachable*/
139139
0;
@@ -146,7 +146,7 @@ void cascaded_property_set_reachable(C? f()) {
146146

147147
/*member: cascaded_property_set_unreachable:doesNotComplete*/
148148
void cascaded_property_set_unreachable(C f()) {
149-
// Reachable since the value returned by f() might come from legacy code
149+
// Unreachable since Dart 3.9.
150150
f()?..field = throw '';
151151
/*stmt: unreachable*/
152152
0;

0 commit comments

Comments
 (0)