[element model] migrate `generic_inferrer_test`

Change-Id: Ie626f94ea74f6d07be517d87c0f0a4a3dda00feb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/405446
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
diff --git a/pkg/analyzer/lib/src/dart/element/generic_inferrer.dart b/pkg/analyzer/lib/src/dart/element/generic_inferrer.dart
index c44fed8..9af8687 100644
--- a/pkg/analyzer/lib/src/dart/element/generic_inferrer.dart
+++ b/pkg/analyzer/lib/src/dart/element/generic_inferrer.dart
@@ -183,6 +183,26 @@
     }
   }
 
+  /// Applies all the argument constraints implied by [parameters] and
+  /// [argumentTypes].
+  void constrainArguments2(
+      {InterfaceElement? genericClass,
+      required List<FormalParameterElementMixin> parameters,
+      required List<TypeImpl> argumentTypes,
+      required AstNodeImpl? nodeForTesting}) {
+    for (int i = 0; i < argumentTypes.length; i++) {
+      // Try to pass each argument to each parameter, recording any type
+      // parameter bounds that were implied by this assignment.
+      constrainArgument(
+        argumentTypes[i],
+        parameters[i].type,
+        parameters[i].name3!,
+        genericClass: genericClass,
+        nodeForTesting: nodeForTesting,
+      );
+    }
+  }
+
   /// Constrain a universal function type [fnType] used in a context
   /// [contextType].
   void constrainGenericFunctionInContext(
diff --git a/pkg/analyzer/test/src/dart/element/generic_inferrer_test.dart b/pkg/analyzer/test/src/dart/element/generic_inferrer_test.dart
index 3be493d..ca93d12 100644
--- a/pkg/analyzer/test/src/dart/element/generic_inferrer_test.dart
+++ b/pkg/analyzer/test/src/dart/element/generic_inferrer_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// ignore_for_file: analyzer_use_new_elements
-
 import 'package:_fe_analyzer_shared/src/type_inference/type_analyzer_operations.dart';
 import 'package:analyzer/dart/ast/token.dart';
 import 'package:analyzer/dart/element/type.dart';
@@ -200,21 +198,21 @@
   /// https://github.com/dart-lang/language/issues/1182#issuecomment-702272641
   void test_demoteType() {
     // <T>(T x) -> void
-    var T = typeParameter('T');
-    var rawType = functionTypeNone(
+    var T = typeParameter2('T');
+    var rawType = functionTypeNone2(
       typeFormals: [T],
       parameters: [
-        requiredParameter(type: typeParameterTypeNone(T)),
+        requiredParameter2(type: typeParameterTypeNone2(T)),
       ],
       returnType: voidNone,
     );
 
-    var S = typeParameter('S');
-    var S_and_int = typeParameterTypeNone(S, promotedBound: intNone);
+    var S = typeParameter2('S');
+    var S_and_int = typeParameterTypeNone2(S, promotedBound: intNone);
 
     var inferredTypes = _inferCall(rawType, [S_and_int]);
     var inferredType = inferredTypes[0] as TypeParameterTypeImpl;
-    expect(inferredType.element, S);
+    expect(inferredType.element3, S);
     expect(inferredType.promotedBound, isNull);
   }
 
@@ -636,10 +634,8 @@
       dataForTesting: null,
       nodeForTesting: null,
     );
-    inferrer.constrainArguments(
-        // TODO(paulberry): eliminate this cast by changing the type of
-        // `FunctionTypeImpl.parameters` to `List<ParameterElementMixin>`.
-        parameters: ft.parameters.cast(),
+    inferrer.constrainArguments2(
+        parameters: ft.formalParameters,
         argumentTypes: arguments,
         nodeForTesting: null);
     var typeArguments = inferrer.chooseFinalTypes();