[dart2js] Migrate instantiation_stub

Change-Id: Ib9cce2bb5f2e2787daac390309418d59ac27fd54
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/267764
Reviewed-by: Nate Biggs <natebiggs@google.com>
diff --git a/pkg/compiler/lib/src/js_emitter/instantiation_stub_generator.dart b/pkg/compiler/lib/src/js_emitter/instantiation_stub_generator.dart
index 5ce1f8f..c6702cf 100644
--- a/pkg/compiler/lib/src/js_emitter/instantiation_stub_generator.dart
+++ b/pkg/compiler/lib/src/js_emitter/instantiation_stub_generator.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.
 
-// @dart = 2.10
-
 library dart2js.js_emitter.instantiation_stub_generator;
 
 import '../common/elements.dart' show JCommonElements, JElementEnvironment;
@@ -12,6 +10,7 @@
 import '../js/js.dart' as jsAst;
 import '../js/js.dart' show js;
 import '../js_backend/namer_interfaces.dart' show Namer;
+import '../js_model/elements.dart' show JField;
 import '../js_model/js_world.dart' show JClosedWorld;
 import '../universe/call_structure.dart' show CallStructure;
 import '../universe/codegen_world_builder.dart';
@@ -92,7 +91,7 @@
       _namer.instanceFieldPropertyName(functionField),
       _namer.invocationName(targetSelector),
       arguments,
-    ]);
+    ]) as jsAst.Fun;
     // TODO(sra): .withSourceInformation(sourceInformation);
 
     jsAst.Name name = _namer.invocationName(callSelector);
@@ -130,12 +129,12 @@
         _emitter.staticFunctionAccess(_commonElements.closureFunctionType),
         _namer.instanceFieldPropertyName(functionField),
         _namer.rtiFieldJsName,
-      ]);
+      ]) as jsAst.Fun;
 
   // Returns all stubs for an instantiation class.
   //
   List<StubMethod> generateStubs(
-      ClassEntity instantiationClass, FunctionEntity member) {
+      ClassEntity instantiationClass, FunctionEntity? member) {
     // 1. Find the number of type parameters in [instantiationClass].
     int typeArgumentCount = _closedWorld.dartTypes
         .getThisType(instantiationClass)
@@ -144,17 +143,16 @@
     assert(typeArgumentCount > 0);
 
     // 2. Find the function field access path.
-    FieldEntity functionField;
+    late FieldEntity functionField;
     _elementEnvironment.forEachInstanceField(instantiationClass,
         (ClassEntity enclosing, FieldEntity field) {
-      if (_closedWorld.fieldAnalysis.getFieldData(field).isElided) return;
+      if (_closedWorld.fieldAnalysis.getFieldData(field as JField).isElided)
+        return;
       if (field.name == '_genericClosure') functionField = field;
     });
-    assert(functionField != null,
-        "Can't find Closure field of $instantiationClass");
 
     String call = _namer.closureInvocationSelectorName;
-    Map<Selector, SelectorConstraints> callSelectors =
+    Map<Selector, SelectorConstraints>? callSelectors =
         _codegenWorld.invocationsByName(call);
 
     Set<ParameterStructure> computeLiveParameterStructures() {
@@ -179,7 +177,7 @@
     // with filled-in type arguments.
 
     if (callSelectors != null) {
-      Set<ParameterStructure> parameterStructures;
+      Set<ParameterStructure>? parameterStructures;
       for (Selector selector in callSelectors.keys) {
         CallStructure callStructure = selector.callStructure;
         if (callStructure.typeArgumentCount != 0) continue;