Fix for element type inference tests.

Change-Id: I17a924126e0f9294f1ad212ebd12c81abca05d16
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97170
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
diff --git a/tests/language_2/control_flow_collections/for_inference_test.dart b/tests/language_2/control_flow_collections/for_inference_test.dart
index 9c462262..54b3141 100644
--- a/tests/language_2/control_flow_collections/for_inference_test.dart
+++ b/tests/language_2/control_flow_collections/for_inference_test.dart
@@ -60,8 +60,8 @@
   Expect.type<List<int>>([for (var i = 1; i < 2; i++) i]);
   Expect.type<List<String>>([for (var i = 1; i < 2; i++) i.toRadixString(10)]);
 
-  // Loop variable type is not pushed into iterable.
-  Expect.listEquals(<int>[1], [for (int i in expectDynamic([1])) i]);
+  // Loop variable type is pushed into sequence.
+  Expect.listEquals(<int>[1], [for (int i in expectIntIterable([1])) i]);
 
   // Loop variable type is pushed into initializer.
   Expect.listEquals(<int>[1], [for (int i = expectInt(1); i < 2; i++) i]);
@@ -71,26 +71,31 @@
   // Lists.
 
   // The context element type is pushed into the body.
-  Expect.listEquals(<int>[1], <int>[for (; false;) expectInt(1)]);
+  Expect.listEquals(<int>[1], <int>[for (var i = 0; i < 1; i++) expectInt(1)]);
 
   // Bottom up-inference from elements is not pushed back down into the body.
-  Expect.listEquals(<int>[1, 2], [1, for (; false;) expectDynamic(2)]);
+  Expect.listEquals(<int>[1, 2],
+      [1, for (var i = 0; i < 1; i++) expectDynamic(2)]);
 
   // Maps.
 
   // The context element type is pushed into the body.
-  Expect.mapEquals(<int, String>{1: "s"},
-      <int, String>{for (; false;) expectInt(1): expectString("s")});
+  Expect.mapEquals(<int, String>{1: "s"}, <int, String>{
+    for (var i = 0; i < 1; i++) expectInt(1): expectString("s")
+  });
 
   // Bottom up-inference from elements is not pushed back down into the body.
-  Expect.mapEquals(<int, String>{1: "s", 2: "t"},
-      {1: "s", for (; false;) expectDynamic(2): expectDynamic("t")});
+  Expect.mapEquals(<int, String>{1: "s", 2: "t"}, {
+    1: "s",
+    for (var i = 0; i < 1; i++) expectDynamic(2): expectDynamic("t")
+  });
 
   // Sets.
 
   // The context element type is pushed into the body.
-  Expect.setEquals(<int>{1}, <int>{for (; false;) expectInt(1)});
+  Expect.setEquals(<int>{1}, <int>{for (var i = 0; i < 1; i++) expectInt(1)});
 
   // Bottom up-inference from elements is not pushed back down into the body.
-  Expect.setEquals(<int>{1, 2}, {1, for (; false;) expectDynamic(2)});
+  Expect.setEquals(<int>{1, 2},
+      {1, for (var i = 0; i < 1; i++) expectDynamic(2)});
 }
diff --git a/tests/language_2/control_flow_collections/utils.dart b/tests/language_2/control_flow_collections/utils.dart
index 9684b3d..796c93d 100644
--- a/tests/language_2/control_flow_collections/utils.dart
+++ b/tests/language_2/control_flow_collections/utils.dart
@@ -48,6 +48,11 @@
   return value;
 }
 
+Iterable<T> expectIntIterable<T>(dynamic value) {
+  Expect.identical(int, T);
+  return value;
+}
+
 Set<T> expectIntSet<T>() {
   Expect.identical(int, T);
   return Set();