@@ -227,33 +227,6 @@ void g() {
227227 assertDetail (detail: regions[0 ].details[0 ], offset: 104 , length: 1 );
228228 }
229229
230- test_exactNullable_exactNullable () async {
231- UnitInfo unit = await buildInfoForSingleTestFile ('''
232- void g(List<int> list1, List<int> list2) {
233- list1[0] = null;
234- list2[0] = list1[0];
235- }
236- ''' , migratedContent: '''
237- void g(List<int?> list1, List<int?> list2) {
238- list1[0] = null;
239- list2[0] = list1[0];
240- }
241- ''' );
242- List <RegionInfo > regions = unit.regions;
243- expect (regions, hasLength (4 ));
244- // regions[0] is the hard edge that list1 is unconditionally indexed
245- assertRegion (region: regions[1 ], offset: 15 , details: [
246- "An explicit 'null' is assigned" ,
247- // TODO(mfairhurst): Fix this bug.
248- 'exact nullable node with no info (Substituted(type(32), migrated))'
249- ]);
250- // regions[2] is the hard edge that list2 is unconditionally indexed
251- assertRegion (
252- region: regions[3 ],
253- offset: 33 ,
254- details: ["A nullable value is assigned" ]);
255- }
256-
257230 test_exactNullable () async {
258231 UnitInfo unit = await buildInfoForSingleTestFile ('''
259232void f(List<int> list) {
@@ -284,6 +257,33 @@ void g() {
284257 details: ["This is later required to accept null." ]);
285258 }
286259
260+ test_exactNullable_exactNullable () async {
261+ UnitInfo unit = await buildInfoForSingleTestFile ('''
262+ void g(List<int> list1, List<int> list2) {
263+ list1[0] = null;
264+ list2[0] = list1[0];
265+ }
266+ ''' , migratedContent: '''
267+ void g(List<int?> list1, List<int?> list2) {
268+ list1[0] = null;
269+ list2[0] = list1[0];
270+ }
271+ ''' );
272+ List <RegionInfo > regions = unit.regions;
273+ expect (regions, hasLength (4 ));
274+ // regions[0] is the hard edge that list1 is unconditionally indexed
275+ assertRegion (region: regions[1 ], offset: 15 , details: [
276+ "An explicit 'null' is assigned" ,
277+ // TODO(mfairhurst): Fix this bug.
278+ 'exact nullable node with no info (Substituted(type(32), migrated))'
279+ ]);
280+ // regions[2] is the hard edge that list2 is unconditionally indexed
281+ assertRegion (
282+ region: regions[3 ],
283+ offset: 33 ,
284+ details: ["A nullable value is assigned" ]);
285+ }
286+
287287 test_expressionFunctionReturnTarget () async {
288288 UnitInfo unit = await buildInfoForSingleTestFile ('''
289289String g() => 1 == 2 ? "Hello" : null;
@@ -321,6 +321,26 @@ class A {
321321 ]);
322322 }
323323
324+ test_field_fieldFormalInitializer_optional_defaultNull () async {
325+ UnitInfo unit = await buildInfoForSingleTestFile ('''
326+ class A {
327+ int _f;
328+ A([this._f = null]);
329+ }
330+ ''' , migratedContent: '''
331+ class A {
332+ int? _f;
333+ A([this._f = null]);
334+ }
335+ ''' );
336+ List <RegionInfo > regions = unit.regions;
337+ expect (regions, hasLength (1 ));
338+ assertRegion (region: regions[0 ], offset: 15 , details: [
339+ "This field is initialized by an optional field formal parameter that "
340+ "has an explicit default value of 'null'"
341+ ]);
342+ }
343+
324344 test_field_fieldFormalInitializer_required () async {
325345 UnitInfo unit = await buildInfoForSingleTestFile ('''
326346class A {
@@ -679,28 +699,25 @@ void g() {
679699 details: ["An explicit 'null' is passed as an argument" ]);
680700 }
681701
682- @failingTest
683702 test_parameter_fromInvocation_implicit () async {
684- // Failing because the upstream edge ("always -(hard)-> type(13)")
685- // associated with the reason (a _NullabilityNodeSimple) had a `null` origin
686- // when the listener's `graphEdge` method was called.
687703 UnitInfo unit = await buildInfoForSingleTestFile ('''
688704void f(String s) {}
689705void g(p) {
690706 f(p);
691707}
708+ void h() => g(null);
692709''' , migratedContent: '''
693710void f(String? s) {}
694711void g(p) {
695712 f(p);
696713}
714+ void h() => g(null);
697715''' );
698716 List <RegionInfo > regions = unit.regions;
699717 expect (regions, hasLength (1 ));
700- assertRegion (
701- region: regions[0 ],
702- offset: 13 ,
703- details: ["A nullable value is explicitly passed as an argument" ]);
718+ assertRegion (region: regions[0 ], offset: 13 , details: [
719+ "A dynamic value, which is nullable is passed as an argument"
720+ ]);
704721 }
705722
706723 test_parameter_fromMultipleOverridden_explicit () async {
@@ -857,10 +874,7 @@ void g({int? i}) {}
857874 assertDetail (detail: regions[0 ].details[0 ], offset: 11 , length: 3 );
858875 }
859876
860- @failingTest
861877 test_parameter_optional_explicitDefault_null () async {
862- // Failing because we appear to never get an origin when the upstream node
863- // for an edge is 'always'.
864878 UnitInfo unit = await buildInfoForSingleTestFile ('''
865879void f({String s = null}) {}
866880''' , migratedContent: '''
@@ -874,23 +888,20 @@ void f({String? s = null}) {}
874888 details: ["This parameter has an explicit default value of 'null'" ]);
875889 }
876890
877- @failingTest
878891 test_parameter_optional_explicitDefault_nullable () async {
879- // Failing because we appear to never get an origin when the upstream node
880- // for an edge is 'always'.
881892 UnitInfo unit = await buildInfoForSingleTestFile ('''
882- const sd = null;
893+ String sd = null;
883894void f({String s = sd}) {}
884895''' , migratedContent: '''
885- const sd = null;
896+ String? sd = null;
886897void f({String? s = sd}) {}
887898''' );
888899 List <RegionInfo > regions = unit.fixRegions;
889- expect (regions, hasLength (1 ));
900+ expect (regions, hasLength (2 ));
890901 assertRegion (
891- region: regions[0 ],
892- offset: 31 ,
893- details: ["This parameter has an explicit default value of 'null' " ]);
902+ region: regions[1 ],
903+ offset: 33 ,
904+ details: ["This parameter has a nullable default value" ]);
894905 }
895906
896907 test_parameter_optional_implicitDefault_named () async {
0 commit comments