Reland "[cfe] Handle spread map entries of static type Null"

This is a reland of ccd2c85a1ace40b6a262b5230f11dfc26459286a

Original change's description:
> [cfe] Handle spread map entries of static type Null
> 
> Change-Id: I164b3fa471deb65da93ecfd60ee836ec22eb93e1
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/96080
> Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
> Reviewed-by: Kevin Millikin <kmillikin@google.com>

Change-Id: I4519970d8259481e137424f3506b7fb97307b14a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/96134
Reviewed-by: Régis Crelier <regis@google.com>
diff --git a/pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart b/pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart
index 52e701e..adfdb18 100644
--- a/pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart
@@ -800,14 +800,18 @@
   // spreadMapEntryType and stores them in output in positions offset and offset
   // + 1.  If the types can't be calculated, for example, if spreadMapEntryType
   // is a function type, the original values in output are preserved.
-  void storeSpreadMapEntryElementTypes(
-      DartType spreadMapEntryType, List<DartType> output, int offset) {
+  void storeSpreadMapEntryElementTypes(DartType spreadMapEntryType,
+      bool isNullAware, List<DartType> output, int offset) {
     if (spreadMapEntryType is InterfaceType) {
       InterfaceType supertype = inferrer.typeSchemaEnvironment
           .getTypeAsInstanceOf(spreadMapEntryType, inferrer.coreTypes.mapClass);
-      if (supertype == null) return null;
-      output[offset] = supertype.typeArguments[0];
-      output[offset + 1] = supertype.typeArguments[1];
+      if (supertype != null) {
+        output[offset] = supertype.typeArguments[0];
+        output[offset + 1] = supertype.typeArguments[1];
+      } else if (spreadMapEntryType.classNode == inferrer.coreTypes.nullClass &&
+          isNullAware) {
+        output[offset] = output[offset + 1] = spreadMapEntryType;
+      }
     }
     if (spreadMapEntryType is DynamicType) {
       output[offset] = output[offset + 1] = const DynamicType();
@@ -880,9 +884,9 @@
         cachedValues[i] = node.entries[i].value;
       }
     }
-    int iterableSpreadOffset = null;
-    int mapSpreadOffset = null;
-    int mapEntryOffset = null;
+    int iterableSpreadOffset = -1;
+    int mapSpreadOffset = -1;
+    int mapEntryOffset = -1;
     if (inferenceNeeded || typeChecksNeeded) {
       DartType spreadTypeContext = const UnknownType();
       if (typeContextIsIterable && !typeContextIsMap) {
@@ -925,7 +929,7 @@
           actualTypes.add(const DynamicType());
           actualTypes.add(const DynamicType());
           storeSpreadMapEntryElementTypes(
-              spreadMapEntryType, actualTypes, length);
+              spreadMapEntryType, entry.isNullAware, actualTypes, length);
         } else {
           Expression key = entry.key;
           inferrer.inferExpression(key, inferredKeyType, true,
@@ -944,16 +948,15 @@
       }
     }
     if (inferenceNeeded) {
-      bool canBeSet = mapSpreadOffset == null &&
-          mapEntryOffset == null &&
-          !typeContextIsMap;
-      bool canBeMap = iterableSpreadOffset == null && !typeContextIsIterable;
+      bool canBeSet =
+          mapSpreadOffset == -1 && mapEntryOffset == -1 && !typeContextIsMap;
+      bool canBeMap = iterableSpreadOffset == -1 && !typeContextIsIterable;
       if (canBeSet && !canBeMap) {
         List<Expression> setElements = <Expression>[];
         for (int i = 0; i < node.entries.length; ++i) {
           SpreadMapEntry entry = node.entries[i];
-          // TODO(dmitryas):  Add support for null-aware spreads.
-          setElements.add(new SpreadElement(entry.expression, false));
+          setElements
+              .add(new SpreadElement(entry.expression, entry.isNullAware));
         }
         SetLiteralJudgment setLiteral = new SetLiteralJudgment(setElements,
             typeArgument: const ImplicitTypeArgument(), isConst: node.isConst)
@@ -1019,19 +1022,31 @@
         if (entry is SpreadMapEntry) {
           DartType spreadMapEntryType = spreadMapEntryTypes[i];
           spreadMapEntryElementTypes[0] = spreadMapEntryElementTypes[1] = null;
-          storeSpreadMapEntryElementTypes(
-              spreadMapEntryType, spreadMapEntryElementTypes, 0);
+          storeSpreadMapEntryElementTypes(spreadMapEntryType, entry.isNullAware,
+              spreadMapEntryElementTypes, 0);
           if (spreadMapEntryElementTypes[0] == null) {
-            node.replaceChild(
-                node.entries[i],
-                new MapEntry(
-                    inferrer.helper.desugarSyntheticExpression(inferrer.helper
-                        .buildProblem(
-                            templateSpreadMapEntryTypeMismatch
-                                .withArguments(spreadMapEntryType),
-                            entry.expression.fileOffset,
-                            1)),
-                    new NullLiteral()));
+            if (spreadMapEntryType is InterfaceType &&
+                spreadMapEntryType.classNode == inferrer.coreTypes.nullClass &&
+                !entry.isNullAware) {
+              node.replaceChild(
+                  node.entries[i],
+                  new MapEntry(
+                      inferrer.helper.desugarSyntheticExpression(inferrer.helper
+                          .buildProblem(messageNonNullAwareSpreadIsNull,
+                              entry.expression.fileOffset, 1)),
+                      new NullLiteral()));
+            } else {
+              node.replaceChild(
+                  node.entries[i],
+                  new MapEntry(
+                      inferrer.helper.desugarSyntheticExpression(inferrer.helper
+                          .buildProblem(
+                              templateSpreadMapEntryTypeMismatch
+                                  .withArguments(spreadMapEntryType),
+                              entry.expression.fileOffset,
+                              1)),
+                      new NullLiteral()));
+            }
           } else if (spreadMapEntryType is DynamicType) {
             inferrer.ensureAssignable(
                 inferrer.coreTypes.mapClass.rawType,
@@ -1039,38 +1054,33 @@
                 entry.expression,
                 entry.expression.fileOffset);
           } else if (spreadMapEntryType is InterfaceType) {
-            if (spreadMapEntryType.classNode == inferrer.coreTypes.nullClass) {
-              // TODO(dmitryas):  Handle this case when null-aware spreads are
-              // supported by the parser.
-            } else {
-              Expression keyError;
-              Expression valueError;
-              if (!inferrer.isAssignable(
-                  node.keyType, spreadMapEntryElementTypes[0])) {
-                keyError = inferrer.helper.desugarSyntheticExpression(
-                    inferrer.helper.buildProblem(
-                        templateSpreadMapEntryElementKeyTypeMismatch
-                            .withArguments(
-                                spreadMapEntryElementTypes[0], node.keyType),
-                        entry.expression.fileOffset,
-                        1));
-              }
-              if (!inferrer.isAssignable(
-                  node.valueType, spreadMapEntryElementTypes[1])) {
-                valueError = inferrer.helper.desugarSyntheticExpression(
-                    inferrer.helper.buildProblem(
-                        templateSpreadMapEntryElementValueTypeMismatch
-                            .withArguments(
-                                spreadMapEntryElementTypes[1], node.valueType),
-                        entry.expression.fileOffset,
-                        1));
-              }
-              if (keyError != null || valueError != null) {
-                keyError ??= new NullLiteral();
-                valueError ??= new NullLiteral();
-                node.replaceChild(
-                    node.entries[i], new MapEntry(keyError, valueError));
-              }
+            Expression keyError;
+            Expression valueError;
+            if (!inferrer.isAssignable(
+                node.keyType, spreadMapEntryElementTypes[0])) {
+              keyError = inferrer.helper.desugarSyntheticExpression(
+                  inferrer.helper.buildProblem(
+                      templateSpreadMapEntryElementKeyTypeMismatch
+                          .withArguments(
+                              spreadMapEntryElementTypes[0], node.keyType),
+                      entry.expression.fileOffset,
+                      1));
+            }
+            if (!inferrer.isAssignable(
+                node.valueType, spreadMapEntryElementTypes[1])) {
+              valueError = inferrer.helper.desugarSyntheticExpression(
+                  inferrer.helper.buildProblem(
+                      templateSpreadMapEntryElementValueTypeMismatch
+                          .withArguments(
+                              spreadMapEntryElementTypes[1], node.valueType),
+                      entry.expression.fileOffset,
+                      1));
+            }
+            if (keyError != null || valueError != null) {
+              keyError ??= new NullLiteral();
+              valueError ??= new NullLiteral();
+              node.replaceChild(
+                  node.entries[i], new MapEntry(keyError, valueError));
             }
           }
         } else {
diff --git a/pkg/front_end/testcases/spread_collection_inference.dart b/pkg/front_end/testcases/spread_collection_inference.dart
index 3a9201a..6225eca 100644
--- a/pkg/front_end/testcases/spread_collection_inference.dart
+++ b/pkg/front_end/testcases/spread_collection_inference.dart
@@ -118,9 +118,21 @@
 
   Set<int> set70 = <int>{... /*@error=NonNullAwareSpreadIsNull*/ null};
 
+  var /*@type=Set<dynamic>*/ set71ambiguous = /*@typeArgs=dynamic*/
+    {... /*@error=NonNullAwareSpreadIsNull*/ null, ... /*@typeArgs=dynamic*/
+      []};
+
+  Map<String, int> map70 = <String, int>{... /*@error=NonNullAwareSpreadIsNull*/
+    null};
+
   List<int> lhs80 = <int>[...?null];
 
   Set<int> set80 = <int>{...?null};
+
+  var /*@type=Set<dynamic>*/ set81ambiguous = /*@typeArgs=dynamic*/
+    {...?null, ... /*@typeArgs=dynamic*/ []};
+
+  Map<String, int> map80 = <String, int>{...?null};
 }
 
 main() {}
diff --git a/pkg/front_end/testcases/spread_collection_inference.dart.legacy.expect b/pkg/front_end/testcases/spread_collection_inference.dart.legacy.expect
index 99bbd14..f28dc7f 100644
--- a/pkg/front_end/testcases/spread_collection_inference.dart.legacy.expect
+++ b/pkg/front_end/testcases/spread_collection_inference.dart.legacy.expect
@@ -242,14 +242,62 @@
 //   Set<int> set70 = <int>{... /*@error=NonNullAwareSpreadIsNull*/ null};
 //                          ^^^
 //
-// pkg/front_end/testcases/spread_collection_inference.dart:121:27: Error: Unexpected token '...?'.
+// pkg/front_end/testcases/spread_collection_inference.dart:122:6: Error: Unexpected token '...'.
+//     {... /*@error=NonNullAwareSpreadIsNull*/ null, ... /*@typeArgs=dynamic*/
+//      ^^^
+//
+// pkg/front_end/testcases/spread_collection_inference.dart:122:52: Error: Unexpected token '...'.
+//     {... /*@error=NonNullAwareSpreadIsNull*/ null, ... /*@typeArgs=dynamic*/
+//                                                    ^^^
+//
+// pkg/front_end/testcases/spread_collection_inference.dart:122:46: Error: Expected ':' after this.
+//     {... /*@error=NonNullAwareSpreadIsNull*/ null, ... /*@typeArgs=dynamic*/
+//                                              ^
+//
+// pkg/front_end/testcases/spread_collection_inference.dart:123:7: Error: Expected ':' after this.
+//       []};
+//       ^
+//
+// pkg/front_end/testcases/spread_collection_inference.dart:125:42: Error: Unexpected token '...'.
+//   Map<String, int> map70 = <String, int>{... /*@error=NonNullAwareSpreadIsNull*/
+//                                          ^^^
+//
+// pkg/front_end/testcases/spread_collection_inference.dart:126:5: Error: Expected ':' after this.
+//     null};
+//     ^
+//
+// pkg/front_end/testcases/spread_collection_inference.dart:128:27: Error: Unexpected token '...?'.
 //   List<int> lhs80 = <int>[...?null];
 //                           ^^^^
 //
-// pkg/front_end/testcases/spread_collection_inference.dart:123:26: Error: Unexpected token '...?'.
+// pkg/front_end/testcases/spread_collection_inference.dart:130:26: Error: Unexpected token '...?'.
 //   Set<int> set80 = <int>{...?null};
 //                          ^^^^
 //
+// pkg/front_end/testcases/spread_collection_inference.dart:133:6: Error: Unexpected token '...?'.
+//     {...?null, ... /*@typeArgs=dynamic*/ []};
+//      ^^^^
+//
+// pkg/front_end/testcases/spread_collection_inference.dart:133:16: Error: Unexpected token '...'.
+//     {...?null, ... /*@typeArgs=dynamic*/ []};
+//                ^^^
+//
+// pkg/front_end/testcases/spread_collection_inference.dart:133:10: Error: Expected ':' after this.
+//     {...?null, ... /*@typeArgs=dynamic*/ []};
+//          ^
+//
+// pkg/front_end/testcases/spread_collection_inference.dart:133:42: Error: Expected ':' after this.
+//     {...?null, ... /*@typeArgs=dynamic*/ []};
+//                                          ^
+//
+// pkg/front_end/testcases/spread_collection_inference.dart:135:42: Error: Unexpected token '...?'.
+//   Map<String, int> map80 = <String, int>{...?null};
+//                                          ^^^^
+//
+// pkg/front_end/testcases/spread_collection_inference.dart:135:46: Error: Expected ':' after this.
+//   Map<String, int> map80 = <String, int>{...?null};
+//                                              ^
+//
 import self as self;
 import "dart:core" as core;
 
@@ -297,7 +345,11 @@
   core::Map<core::String, core::String> map61 = <core::String, core::String>{};
   core::List<core::int> lhs70 = <core::int>[null];
   core::Set<core::int> set70 = <core::int>{null};
+  dynamic set71ambiguous = <dynamic, dynamic>{};
+  core::Map<core::String, core::int> map70 = <core::String, core::int>{};
   core::List<core::int> lhs80 = <core::int>[null];
   core::Set<core::int> set80 = <core::int>{null};
+  dynamic set81ambiguous = <dynamic, dynamic>{};
+  core::Map<core::String, core::int> map80 = <core::String, core::int>{};
 }
 static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/spread_collection_inference.dart.legacy.transformed.expect b/pkg/front_end/testcases/spread_collection_inference.dart.legacy.transformed.expect
index 99bbd14..f28dc7f 100644
--- a/pkg/front_end/testcases/spread_collection_inference.dart.legacy.transformed.expect
+++ b/pkg/front_end/testcases/spread_collection_inference.dart.legacy.transformed.expect
@@ -242,14 +242,62 @@
 //   Set<int> set70 = <int>{... /*@error=NonNullAwareSpreadIsNull*/ null};
 //                          ^^^
 //
-// pkg/front_end/testcases/spread_collection_inference.dart:121:27: Error: Unexpected token '...?'.
+// pkg/front_end/testcases/spread_collection_inference.dart:122:6: Error: Unexpected token '...'.
+//     {... /*@error=NonNullAwareSpreadIsNull*/ null, ... /*@typeArgs=dynamic*/
+//      ^^^
+//
+// pkg/front_end/testcases/spread_collection_inference.dart:122:52: Error: Unexpected token '...'.
+//     {... /*@error=NonNullAwareSpreadIsNull*/ null, ... /*@typeArgs=dynamic*/
+//                                                    ^^^
+//
+// pkg/front_end/testcases/spread_collection_inference.dart:122:46: Error: Expected ':' after this.
+//     {... /*@error=NonNullAwareSpreadIsNull*/ null, ... /*@typeArgs=dynamic*/
+//                                              ^
+//
+// pkg/front_end/testcases/spread_collection_inference.dart:123:7: Error: Expected ':' after this.
+//       []};
+//       ^
+//
+// pkg/front_end/testcases/spread_collection_inference.dart:125:42: Error: Unexpected token '...'.
+//   Map<String, int> map70 = <String, int>{... /*@error=NonNullAwareSpreadIsNull*/
+//                                          ^^^
+//
+// pkg/front_end/testcases/spread_collection_inference.dart:126:5: Error: Expected ':' after this.
+//     null};
+//     ^
+//
+// pkg/front_end/testcases/spread_collection_inference.dart:128:27: Error: Unexpected token '...?'.
 //   List<int> lhs80 = <int>[...?null];
 //                           ^^^^
 //
-// pkg/front_end/testcases/spread_collection_inference.dart:123:26: Error: Unexpected token '...?'.
+// pkg/front_end/testcases/spread_collection_inference.dart:130:26: Error: Unexpected token '...?'.
 //   Set<int> set80 = <int>{...?null};
 //                          ^^^^
 //
+// pkg/front_end/testcases/spread_collection_inference.dart:133:6: Error: Unexpected token '...?'.
+//     {...?null, ... /*@typeArgs=dynamic*/ []};
+//      ^^^^
+//
+// pkg/front_end/testcases/spread_collection_inference.dart:133:16: Error: Unexpected token '...'.
+//     {...?null, ... /*@typeArgs=dynamic*/ []};
+//                ^^^
+//
+// pkg/front_end/testcases/spread_collection_inference.dart:133:10: Error: Expected ':' after this.
+//     {...?null, ... /*@typeArgs=dynamic*/ []};
+//          ^
+//
+// pkg/front_end/testcases/spread_collection_inference.dart:133:42: Error: Expected ':' after this.
+//     {...?null, ... /*@typeArgs=dynamic*/ []};
+//                                          ^
+//
+// pkg/front_end/testcases/spread_collection_inference.dart:135:42: Error: Unexpected token '...?'.
+//   Map<String, int> map80 = <String, int>{...?null};
+//                                          ^^^^
+//
+// pkg/front_end/testcases/spread_collection_inference.dart:135:46: Error: Expected ':' after this.
+//   Map<String, int> map80 = <String, int>{...?null};
+//                                              ^
+//
 import self as self;
 import "dart:core" as core;
 
@@ -297,7 +345,11 @@
   core::Map<core::String, core::String> map61 = <core::String, core::String>{};
   core::List<core::int> lhs70 = <core::int>[null];
   core::Set<core::int> set70 = <core::int>{null};
+  dynamic set71ambiguous = <dynamic, dynamic>{};
+  core::Map<core::String, core::int> map70 = <core::String, core::int>{};
   core::List<core::int> lhs80 = <core::int>[null];
   core::Set<core::int> set80 = <core::int>{null};
+  dynamic set81ambiguous = <dynamic, dynamic>{};
+  core::Map<core::String, core::int> map80 = <core::String, core::int>{};
 }
 static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/spread_collection_inference.dart.strong.expect b/pkg/front_end/testcases/spread_collection_inference.dart.strong.expect
index 4f527a6..b6afa97 100644
--- a/pkg/front_end/testcases/spread_collection_inference.dart.strong.expect
+++ b/pkg/front_end/testcases/spread_collection_inference.dart.strong.expect
@@ -95,6 +95,14 @@
 //   Set<int> set70 = <int>{... /*@error=NonNullAwareSpreadIsNull*/ null};
 //                                                                  ^
 //
+// pkg/front_end/testcases/spread_collection_inference.dart:122:46: Error: Can't spread a value with static type Null.
+//     {... /*@error=NonNullAwareSpreadIsNull*/ null, ... /*@typeArgs=dynamic*/
+//                                              ^
+//
+// pkg/front_end/testcases/spread_collection_inference.dart:126:5: Error: Can't spread a value with static type Null.
+//     null};
+//     ^
+//
 import self as self;
 import "dart:core" as core;
 import "dart:collection" as col;
@@ -300,19 +308,46 @@
   core::Set<core::int> set70 = let final core::Set<core::int> #t62 = col::LinkedHashSet::•<core::int>() in let final dynamic #t63 = #t62.{core::Set::add}(invalid-expression "pkg/front_end/testcases/spread_collection_inference.dart:119:66: Error: Can't spread a value with static type Null.
   Set<int> set70 = <int>{... /*@error=NonNullAwareSpreadIsNull*/ null};
                                                                  ^") in #t62;
-  core::List<core::int> lhs80 = block {
-    final core::List<core::int> #t64 = <core::int>[];
-    final dynamic #t65 = null;
-    if(!#t65.{core::Object::==}(null))
-      for (final core::int #t66 in #t65)
-        #t64.{core::List::add}(#t66);
+  core::Set<dynamic> set71ambiguous = block {
+    final core::Set<dynamic> #t64 = col::LinkedHashSet::•<dynamic>();
+    #t64.{core::Set::add}(invalid-expression "pkg/front_end/testcases/spread_collection_inference.dart:122:46: Error: Can't spread a value with static type Null.
+    {... /*@error=NonNullAwareSpreadIsNull*/ null, ... /*@typeArgs=dynamic*/
+                                             ^");
+    for (final dynamic #t65 in <dynamic>[])
+      #t64.{core::Set::add}(#t65);
   } =>#t64;
+  core::Map<core::String, core::int> map70 = <core::String, core::int>{invalid-expression "pkg/front_end/testcases/spread_collection_inference.dart:126:5: Error: Can't spread a value with static type Null.
+    null};
+    ^": null};
+  core::List<core::int> lhs80 = block {
+    final core::List<core::int> #t66 = <core::int>[];
+    final dynamic #t67 = null;
+    if(!#t67.{core::Object::==}(null))
+      for (final core::int #t68 in #t67)
+        #t66.{core::List::add}(#t68);
+  } =>#t66;
   core::Set<core::int> set80 = block {
-    final core::Set<core::int> #t67 = col::LinkedHashSet::•<core::int>();
-    final dynamic #t68 = null;
-    if(!#t68.{core::Object::==}(null))
-      for (final core::int #t69 in #t68)
-        #t67.{core::Set::add}(#t69);
-  } =>#t67;
+    final core::Set<core::int> #t69 = col::LinkedHashSet::•<core::int>();
+    final dynamic #t70 = null;
+    if(!#t70.{core::Object::==}(null))
+      for (final core::int #t71 in #t70)
+        #t69.{core::Set::add}(#t71);
+  } =>#t69;
+  core::Set<dynamic> set81ambiguous = block {
+    final core::Set<dynamic> #t72 = col::LinkedHashSet::•<dynamic>();
+    final dynamic #t73 = null;
+    if(!#t73.{core::Object::==}(null))
+      for (final dynamic #t74 in #t73)
+        #t72.{core::Set::add}(#t74);
+    for (final dynamic #t75 in <dynamic>[])
+      #t72.{core::Set::add}(#t75);
+  } =>#t72;
+  core::Map<core::String, core::int> map80 = block {
+    final core::Map<core::String, core::int> #t76 = <core::String, core::int>{};
+    final core::Map<dynamic, dynamic> #t77 = null;
+    if(!#t77.{core::Object::==}(null))
+      for (final core::MapEntry<core::String, core::int> #t78 in #t77)
+        #t76.{core::Map::[]=}(#t78.{core::MapEntry::key}, #t78.{core::MapEntry::value});
+  } =>#t76;
 }
 static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/spread_collection_inference.dart.strong.transformed.expect b/pkg/front_end/testcases/spread_collection_inference.dart.strong.transformed.expect
index 7b62bb5..3ba19f9 100644
--- a/pkg/front_end/testcases/spread_collection_inference.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/spread_collection_inference.dart.strong.transformed.expect
@@ -95,6 +95,14 @@
 //   Set<int> set70 = <int>{... /*@error=NonNullAwareSpreadIsNull*/ null};
 //                                                                  ^
 //
+// pkg/front_end/testcases/spread_collection_inference.dart:122:46: Error: Can't spread a value with static type Null.
+//     {... /*@error=NonNullAwareSpreadIsNull*/ null, ... /*@typeArgs=dynamic*/
+//                                              ^
+//
+// pkg/front_end/testcases/spread_collection_inference.dart:126:5: Error: Can't spread a value with static type Null.
+//     null};
+//     ^
+//
 import self as self;
 import "dart:core" as core;
 import "dart:collection" as col;
@@ -300,19 +308,46 @@
   core::Set<core::int> set70 = let final core::Set<core::int> #t62 = col::LinkedHashSet::•<core::int>() in let final core::bool #t63 = #t62.{core::Set::add}(invalid-expression "pkg/front_end/testcases/spread_collection_inference.dart:119:66: Error: Can't spread a value with static type Null.
   Set<int> set70 = <int>{... /*@error=NonNullAwareSpreadIsNull*/ null};
                                                                  ^") in #t62;
-  core::List<core::int> lhs80 = block {
-    final core::List<core::int> #t64 = <core::int>[];
-    final dynamic #t65 = null;
-    if(!#t65.{core::Object::==}(null))
-      for (final core::int #t66 in #t65)
-        #t64.{core::List::add}(#t66);
+  core::Set<dynamic> set71ambiguous = block {
+    final core::Set<dynamic> #t64 = col::LinkedHashSet::•<dynamic>();
+    #t64.{core::Set::add}(invalid-expression "pkg/front_end/testcases/spread_collection_inference.dart:122:46: Error: Can't spread a value with static type Null.
+    {... /*@error=NonNullAwareSpreadIsNull*/ null, ... /*@typeArgs=dynamic*/
+                                             ^");
+    for (final dynamic #t65 in <dynamic>[])
+      #t64.{core::Set::add}(#t65);
   } =>#t64;
+  core::Map<core::String, core::int> map70 = <core::String, core::int>{invalid-expression "pkg/front_end/testcases/spread_collection_inference.dart:126:5: Error: Can't spread a value with static type Null.
+    null};
+    ^": null};
+  core::List<core::int> lhs80 = block {
+    final core::List<core::int> #t66 = <core::int>[];
+    final dynamic #t67 = null;
+    if(!#t67.{core::Object::==}(null))
+      for (final core::int #t68 in #t67)
+        #t66.{core::List::add}(#t68);
+  } =>#t66;
   core::Set<core::int> set80 = block {
-    final core::Set<core::int> #t67 = col::LinkedHashSet::•<core::int>();
-    final dynamic #t68 = null;
-    if(!#t68.{core::Object::==}(null))
-      for (final core::int #t69 in #t68)
-        #t67.{core::Set::add}(#t69);
-  } =>#t67;
+    final core::Set<core::int> #t69 = col::LinkedHashSet::•<core::int>();
+    final dynamic #t70 = null;
+    if(!#t70.{core::Object::==}(null))
+      for (final core::int #t71 in #t70)
+        #t69.{core::Set::add}(#t71);
+  } =>#t69;
+  core::Set<dynamic> set81ambiguous = block {
+    final core::Set<dynamic> #t72 = col::LinkedHashSet::•<dynamic>();
+    final dynamic #t73 = null;
+    if(!#t73.{core::Object::==}(null))
+      for (final dynamic #t74 in #t73)
+        #t72.{core::Set::add}(#t74);
+    for (final dynamic #t75 in <dynamic>[])
+      #t72.{core::Set::add}(#t75);
+  } =>#t72;
+  core::Map<core::String, core::int> map80 = block {
+    final core::Map<core::String, core::int> #t76 = <core::String, core::int>{};
+    final core::Map<dynamic, dynamic> #t77 = null;
+    if(!#t77.{core::Object::==}(null))
+      for (final core::MapEntry<core::String, core::int> #t78 in #t77)
+        #t76.{core::Map::[]=}(#t78.{core::MapEntry::key}, #t78.{core::MapEntry::value});
+  } =>#t76;
 }
 static method main() → dynamic {}
diff --git a/tests/co19_2/co19_2-kernel.status b/tests/co19_2/co19_2-kernel.status
index 9aa97c8..2ca1873 100644
--- a/tests/co19_2/co19_2-kernel.status
+++ b/tests/co19_2/co19_2-kernel.status
@@ -137,9 +137,14 @@
 Language/Statements/For/syntax_t13: Crash # Assertion error: kernel_shadow_ast.dart: 'receiver == null': is not true.
 Language/Statements/For/syntax_t20: Crash # Assertion error: kernel_shadow_ast.dart: 'receiver == null': is not true.
 LanguageFeatures/Constant_update2018/ShortCircuitOperators_A03_t03: Crash
-LanguageFeatures/Spread-collections/Ambiguity_A02_t02/none: CompileTimeError
+LanguageFeatures/Spread-collections/Ambiguity_A02_t02/01: MissingCompileTimeError
 LanguageFeatures/Spread-collections/Ambiguity_A02_t03: CompileTimeError
+LanguageFeatures/Spread-collections/ConstSpreads_A03_t02/12: MissingCompileTimeError
+LanguageFeatures/Spread-collections/ConstSpreads_A04_t01/01: MissingCompileTimeError
 LanguageFeatures/Spread-collections/ConstSpreads_A04_t01/02: MissingCompileTimeError
+LanguageFeatures/Spread-collections/ConstSpreads_A04_t01/03: MissingCompileTimeError
+LanguageFeatures/Spread-collections/ConstSpreads_A04_t01/04: MissingCompileTimeError
+LanguageFeatures/Spread-collections/ConstSpreads_A04_t01/05: MissingCompileTimeError
 LanguageFeatures/Spread-collections/ConstSpreads_A04_t01/06: MissingCompileTimeError
 LanguageFeatures/Spread-collections/ConstSpreads_A04_t01/07: MissingCompileTimeError
 LanguageFeatures/Spread-collections/ConstSpreads_A04_t01/08: MissingCompileTimeError
@@ -147,8 +152,6 @@
 LanguageFeatures/Spread-collections/DynamicSemantics_Map_A02_t01: CompileTimeError
 LanguageFeatures/Spread-collections/DynamicSemantics_Map_A02_t02: CompileTimeError
 LanguageFeatures/Spread-collections/DynamicSemantics_Map_A02_t03: CompileTimeError
-LanguageFeatures/Spread-collections/DynamicSemantics_Set_A01_t01: CompileTimeError
-LanguageFeatures/Spread-collections/DynamicSemantics_Set_A02_t06: CompileTimeError
 LanguageFeatures/Spread-collections/NullAware_A01_t01: CompileTimeError
 LanguageFeatures/Spread-collections/NullAware_A01_t02: CompileTimeError
 LanguageFeatures/Spread-collections/NullAware_A01_t03: CompileTimeError
@@ -156,8 +159,9 @@
 LanguageFeatures/Spread-collections/NullAware_A01_t05: CompileTimeError
 LanguageFeatures/Spread-collections/NullAware_A01_t06: CompileTimeError
 LanguageFeatures/Spread-collections/StaticSemantic_A04_t01/04: MissingCompileTimeError
+LanguageFeatures/Spread-collections/StaticSemantic_A04_t02/04: MissingCompileTimeError
 LanguageFeatures/Spread-collections/StaticSemantic_A06_t01/04: MissingCompileTimeError
-LanguageFeatures/Spread-collections/TypeInference_A02_t02: CompileTimeError
+LanguageFeatures/Spread-collections/StaticSemantic_A08_t01/02: MissingCompileTimeError
 
 [ $runtime == vm ]
 LibTest/collection/ListBase/ListBase_class_A01_t02: Pass, Slow # Does many calls
@@ -661,38 +665,27 @@
 LanguageFeatures/Spread-collections/Ambiguity_A01_t03: CompileTimeError
 LanguageFeatures/Spread-collections/Ambiguity_A01_t07: CompileTimeError
 LanguageFeatures/Spread-collections/Ambiguity_A02_t01/01: MissingCompileTimeError
-LanguageFeatures/Spread-collections/ConstSpreads_A01_t02: CompileTimeError
 LanguageFeatures/Spread-collections/ConstSpreads_A04_t01/02: MissingCompileTimeError
 LanguageFeatures/Spread-collections/ConstSpreads_A04_t01/06: MissingCompileTimeError
 LanguageFeatures/Spread-collections/ConstSpreads_A04_t01/07: MissingCompileTimeError
 LanguageFeatures/Spread-collections/ConstSpreads_A04_t01/08: MissingCompileTimeError
-LanguageFeatures/Spread-collections/ConstSpreads_A06_t02: CompileTimeError
 LanguageFeatures/Spread-collections/ConstSpreads_A07_t03: CompileTimeError
-LanguageFeatures/Spread-collections/DynamicSemantics_Set_A02_t01: CompileTimeError
-LanguageFeatures/Spread-collections/DynamicSemantics_Set_A02_t02: CompileTimeError
-LanguageFeatures/Spread-collections/DynamicSemantics_Set_A02_t03: CompileTimeError
 LanguageFeatures/Spread-collections/DynamicSemantics_Set_A02_t05: CompileTimeError
 LanguageFeatures/Spread-collections/DynamicSemantics_Set_A02_t07: CompileTimeError
-LanguageFeatures/Spread-collections/DynamicSemantics_Set_A02_t08: CompileTimeError
 LanguageFeatures/Spread-collections/NullAware_A02_t02: CompileTimeError
 LanguageFeatures/Spread-collections/NullAware_A02_t03: CompileTimeError
 LanguageFeatures/Spread-collections/StaticSemantic_A01_t01: CompileTimeError
 LanguageFeatures/Spread-collections/StaticSemantic_A01_t03: CompileTimeError
 LanguageFeatures/Spread-collections/StaticSemantic_A01_t05: CompileTimeError
-LanguageFeatures/Spread-collections/StaticSemantic_A02_t02: CompileTimeError
 LanguageFeatures/Spread-collections/StaticSemantic_A05_t01/none: CompileTimeError
 LanguageFeatures/Spread-collections/StaticSemantic_A05_t02/none: CompileTimeError
 LanguageFeatures/Spread-collections/StaticSemantic_A06_t01/04: MissingCompileTimeError
 LanguageFeatures/Spread-collections/StaticSemantic_A07_t01/none: CompileTimeError
-LanguageFeatures/Spread-collections/StaticSemantic_A08_t01/none: CompileTimeError
 LanguageFeatures/Spread-collections/Syntax_A01_t03: CompileTimeError
-LanguageFeatures/Spread-collections/Syntax_A02_t01: CompileTimeError
-LanguageFeatures/Spread-collections/Syntax_A02_t02: CompileTimeError
 LanguageFeatures/Spread-collections/Syntax_A02_t04: CompileTimeError
 LanguageFeatures/Spread-collections/Syntax_A02_t06: CompileTimeError
 LanguageFeatures/Spread-collections/Syntax_A02_t08: CompileTimeError
 LanguageFeatures/Spread-collections/Syntax_A02_t09: CompileTimeError
-LanguageFeatures/Spread-collections/Syntax_A02_t10: CompileTimeError
 LanguageFeatures/Spread-collections/TypeInference_A01_t01: CompileTimeError
 LanguageFeatures/Spread-collections/TypeInference_A01_t02: CompileTimeError
 LanguageFeatures/Spread-collections/TypeInference_A02_t01: CompileTimeError
diff --git a/tests/language_2/language_2_kernel.status b/tests/language_2/language_2_kernel.status
index 93f247c..94e9d50 100644
--- a/tests/language_2/language_2_kernel.status
+++ b/tests/language_2/language_2_kernel.status
@@ -259,14 +259,11 @@
 spread_collections/const_error_test/08: MissingCompileTimeError
 spread_collections/const_error_test/10: MissingCompileTimeError
 spread_collections/const_error_test/11: MissingCompileTimeError
+spread_collections/const_error_test/12: MissingCompileTimeError
+spread_collections/const_error_test/13: Crash
+spread_collections/const_error_test/14: MissingCompileTimeError
 spread_collections/const_error_test/15: MissingCompileTimeError
-spread_collections/const_test: CompileTimeError
-spread_collections/inference_test: CompileTimeError
-spread_collections/map_set_ambiguity_error_test/00: MissingCompileTimeError
-spread_collections/map_set_ambiguity_error_test/05: MissingCompileTimeError
-spread_collections/map_set_ambiguity_test: CompileTimeError
-spread_collections/spread_test: CompileTimeError
-spread_collections/syntax_test: CompileTimeError
+spread_collections/const_error_test/16: MissingCompileTimeError
 vm/regress_33469_test/01: MissingCompileTimeError
 vm/regress_33469_test/02: MissingCompileTimeError
 vm/regress_33469_test/03: MissingCompileTimeError