Version 2.18.0-68.0.dev

Merge commit '3199e6548f2c73246e3a6310238ac668e1ebc46d' into 'dev'
diff --git a/pkg/analyzer/lib/src/dart/resolver/invocation_inferrer.dart b/pkg/analyzer/lib/src/dart/resolver/invocation_inferrer.dart
index ff27a7f..e1c48ad 100644
--- a/pkg/analyzer/lib/src/dart/resolver/invocation_inferrer.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/invocation_inferrer.dart
@@ -23,8 +23,8 @@
   List<FormalParameter> parameters =
       functionExpression.parameters?.parameters ?? const [];
   Set<Object> result = {};
+  int unnamedParameterIndex = 0;
   for (var formalParameter in parameters) {
-    int unnamedParameterIndex = 0;
     var key = formalParameter.isNamed
         ? formalParameter.identifier?.name ?? ''
         : unnamedParameterIndex++;
diff --git a/pkg/analyzer/test/src/dart/resolution/type_inference/inference_update_1_test.dart b/pkg/analyzer/test/src/dart/resolution/type_inference/inference_update_1_test.dart
index c4ea903..df511ab 100644
--- a/pkg/analyzer/test/src/dart/resolution/type_inference/inference_update_1_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/type_inference/inference_update_1_test.dart
@@ -110,6 +110,30 @@
         _isEnabled ? 'List<int>' : 'List<dynamic>');
   }
 
+  test_horizontal_inference_necessary_due_to_wrong_explicit_parameter_type() async {
+    // In this example, horizontal type inference is needed because although the
+    // type of `y` is explicit, it's actually `x` that would have needed to be
+    // explicit.
+    await assertErrorsInCode('''
+test(List<int> list) {
+  var a = list.fold(0, (x, int y) => x + y);
+}
+''', [
+      error(HintCode.UNUSED_LOCAL_VARIABLE, 29, 1),
+      if (!_isEnabled)
+        error(
+            CompileTimeErrorCode
+                .UNCHECKED_OPERATOR_INVOCATION_OF_NULLABLE_VALUE,
+            62,
+            1),
+    ]);
+    assertType(findElement.localVar('a').type, _isEnabled ? 'int' : 'dynamic');
+    assertType(findElement.parameter('x').type, _isEnabled ? 'int' : 'Object?');
+    assertType(findElement.parameter('y').type, 'int');
+    expect(findNode.binary('+ y').staticElement?.enclosingElement.name,
+        _isEnabled ? 'num' : null);
+  }
+
   test_horizontal_inference_propagate_to_earlier_closure() async {
     await assertErrorsInCode('''
 U f<T, U>(U Function(T) g, T Function() h) => throw '';
diff --git a/tests/language/inference_update_1/horizontal_inference_enabled_test.dart b/tests/language/inference_update_1/horizontal_inference_enabled_test.dart
index 4d9f277..1cbeeda 100644
--- a/tests/language/inference_update_1/horizontal_inference_enabled_test.dart
+++ b/tests/language/inference_update_1/horizontal_inference_enabled_test.dart
@@ -84,6 +84,15 @@
       .expectStaticType<Exactly<Map<List<Object?>, Set<Object?>>>>();
 }
 
+testNecessaryDueToWrongExplicitParameterType(List<int> list) {
+  var a = list.fold(
+      0,
+      (x, int y) =>
+          (x..expectStaticType<Exactly<int>>()) +
+          (y..expectStaticType<Exactly<int>>()));
+  a.expectStaticType<Exactly<int>>();
+}
+
 testPropagateFromContravariantReturnType(
     U Function<T, U>(void Function(T) Function(), U Function(T)) f) {
   f(() => (int i) {}, (x) => [x]..expectStaticType<Exactly<List<int>>>())
diff --git a/tools/VERSION b/tools/VERSION
index d6b04d4..08f5c3e 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
 MAJOR 2
 MINOR 18
 PATCH 0
-PRERELEASE 67
+PRERELEASE 68
 PRERELEASE_PATCH 0
\ No newline at end of file