Add type inference code to generate Instantiation nodes.

Fixes #31586.

Note that none of the back-ends handle Instantiation nodes yet, so the
language_2 tests added in this CL
(instantiate_tearoff_after_contravariance_check_test,
instantiate_tearoff_of_call_test, and instantiate_tearoff_test) fail
pretty much across the board right now.

Includes two fixes to Instantiation.getStaticType and the kernel type checker:

- Previously, they attempted to perform substitution on the full
  function type, which had no effect because the type parameters were
  bound.

- The type checker was not checking that type parameter bounds were
  satisfied.

Note that the front end doesn't yet check that type parameter bounds
are satisfied by the inferred type parameters.  I will address that in
a follow-up CL.

Change-Id: Ib0ad7a5fc5f4a2fdc8c99abe1f2d3d15b21a4974
Reviewed-on: https://dart-review.googlesource.com/29744
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analyzer/test/generated/strong_mode_kernel_test.dart b/pkg/analyzer/test/generated/strong_mode_kernel_test.dart
index a513888..8112f42 100644
--- a/pkg/analyzer/test/generated/strong_mode_kernel_test.dart
+++ b/pkg/analyzer/test/generated/strong_mode_kernel_test.dart
@@ -315,13 +315,6 @@
 
   @override
   @failingTest
-  test_inferGenericInstantiation() async {
-    // Expected: '(dynamic) → dynamic'
-    await super.test_inferGenericInstantiation();
-  }
-
-  @override
-  @failingTest
   test_inferGenericInstantiation2() async {
     // Expected 1 errors of type StrongModeCode.STRONG_MODE_COULD_NOT_INFER, found 0;
     //          1 errors of type StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, found 0
diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart
index ea1cce7..846289e 100644
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart
@@ -1807,7 +1807,11 @@
       target._inferenceNode.resolve();
       target._inferenceNode = null;
     }
-    var inferredType = typeNeeded ? target.getterType : null;
+    var type = target.getterType;
+    if (target is Procedure && target.kind == ProcedureKind.Method) {
+      type = inferrer.instantiateTearOff(type, typeContext, this);
+    }
+    var inferredType = typeNeeded ? type : null;
     inferrer.listener.staticGetExit(this, inferredType);
     return inferredType;
   }
@@ -2470,8 +2474,11 @@
           new InstrumentationValueForType(promotedType));
     }
     this.promotedType = promotedType;
-    var inferredType =
-        typeNeeded ? (promotedType ?? declaredOrInferredType) : null;
+    var type = promotedType ?? declaredOrInferredType;
+    if (variable._isLocalFunction) {
+      type = inferrer.instantiateTearOff(type, typeContext, this);
+    }
+    var inferredType = typeNeeded ? type : null;
     inferrer.listener.variableGetExit(this, inferredType);
     return inferredType;
   }
diff --git a/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart b/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
index ab6c6cc..861eb8b 100644
--- a/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
+++ b/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
@@ -33,6 +33,7 @@
         FunctionNode,
         FunctionType,
         Initializer,
+        Instantiation,
         InterfaceType,
         InvocationExpression,
         Let,
@@ -41,6 +42,7 @@
         Member,
         MethodInvocation,
         Name,
+        NamedExpression,
         Procedure,
         ProcedureKind,
         PropertyGet,
@@ -742,7 +744,10 @@
 
   /// Determines the dispatch category of a [PropertyGet] and adds an "as" check
   /// if necessary due to contravariance.
-  void handlePropertyGetContravariance(
+  ///
+  /// Returns the "as" check if it was added; otherwise returns the original
+  /// expression.
+  Expression handlePropertyGetContravariance(
       Expression receiver,
       Object interfaceMember,
       PropertyGet desugaredGet,
@@ -763,13 +768,14 @@
         interfaceMember is Procedure) {
       checkReturn = interfaceMember.isGenericContravariant;
     }
+    var replacedExpression = desugaredGet ?? expression;
     if (checkReturn) {
-      var expressionToReplace = desugaredGet ?? expression;
-      expressionToReplace.parent.replaceChild(
-          expressionToReplace,
-          new AsExpression(expressionToReplace, inferredType)
-            ..isTypeError = true
-            ..fileOffset = fileOffset);
+      var expressionToReplace = replacedExpression;
+      var parent = expressionToReplace.parent;
+      replacedExpression = new AsExpression(expressionToReplace, inferredType)
+        ..isTypeError = true
+        ..fileOffset = fileOffset;
+      parent.replaceChild(expressionToReplace, replacedExpression);
     }
     if (instrumentation != null) {
       int offset = expression.fileOffset;
@@ -790,6 +796,7 @@
             new InstrumentationValueForType(inferredType));
       }
     }
+    return replacedExpression;
   }
 
   /// Determines the dispatch category of a [PropertySet].
@@ -976,6 +983,14 @@
             : formalType;
         var actualType = actualTypes[i];
         var expression = expressions[i];
+        // If the expression was replaced during type inference, e.g. due
+        // to insertion of an Instantiation node, we need to find the replaced
+        // expression.  We can do so by walking parent pointers.
+        while (true) {
+          var parent = expression.parent;
+          if (identical(parent, arguments) || parent is NamedExpression) break;
+          expression = parent;
+        }
         checkAssignability(
             expectedType, actualType, expression, expression.fileOffset);
       }
@@ -1248,9 +1263,14 @@
       }
     }
     var inferredType = getCalleeType(interfaceMember, receiverType);
-    // TODO(paulberry): Infer tear-off type arguments if appropriate.
-    handlePropertyGetContravariance(receiver, interfaceMember, desugaredGet,
-        expression, inferredType, fileOffset);
+    var replacedExpression = handlePropertyGetContravariance(receiver,
+        interfaceMember, desugaredGet, expression, inferredType, fileOffset);
+    if ((interfaceMember is Procedure &&
+            interfaceMember.kind == ProcedureKind.Method) ||
+        interfaceMember == 'call') {
+      inferredType =
+          instantiateTearOff(inferredType, typeContext, replacedExpression);
+    }
     if (identical(interfaceMember, 'call')) {
       listener.propertyGetExitCall(expression, inferredType);
     } else {
@@ -1275,6 +1295,36 @@
   /// the statement type and calls the appropriate specialized "infer" method.
   void inferStatement(Statement statement);
 
+  /// Performs the type inference steps necessary to instantiate a tear-off
+  /// (if necessary).
+  DartType instantiateTearOff(
+      DartType tearoffType, DartType context, Expression expression) {
+    if (strongMode &&
+        tearoffType is FunctionType &&
+        context is FunctionType &&
+        context.typeParameters.isEmpty) {
+      var typeParameters = tearoffType.typeParameters;
+      if (typeParameters.isNotEmpty) {
+        var inferredTypes = new List<DartType>.filled(
+            typeParameters.length, const UnknownType());
+        var instantiatedType = tearoffType.withoutTypeParameters;
+        typeSchemaEnvironment.inferGenericFunctionOrType(
+            instantiatedType, typeParameters, [], [], context, inferredTypes);
+        if (!isTopLevel) {
+          var parent = expression.parent;
+          parent.replaceChild(
+              expression,
+              new Instantiation(expression, inferredTypes)
+                ..fileOffset = expression.fileOffset);
+        }
+        var substitution =
+            Substitution.fromPairs(typeParameters, inferredTypes);
+        return substitution.substituteType(instantiatedType);
+      }
+    }
+    return tearoffType;
+  }
+
   /// Determines the dispatch category of a [MethodInvocation] and returns a
   /// boolean indicating whether an "as" check will need to be added due to
   /// contravariance.
diff --git a/pkg/front_end/testcases/ast_builder.status b/pkg/front_end/testcases/ast_builder.status
index 7f8b524..60e5a87 100644
--- a/pkg/front_end/testcases/ast_builder.status
+++ b/pkg/front_end/testcases/ast_builder.status
@@ -60,6 +60,9 @@
 inference/infer_local_function_referenced_before_declaration: Crash
 inference/infer_rethrow: Crash
 inference/infer_statics_transitively3: Crash
+inference/instantiate_tearoff: Crash
+inference/instantiate_tearoff_after_contravariance_check: Crash
+inference/instantiate_tearoff_of_call: Crash
 inference/lambda_does_not_have_propagated_type_hint: Crash
 inference/super_initializer: Crash
 inference/super_initializer_substitution: Crash
diff --git a/pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart.strong.expect b/pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart.strong.expect
index 1f6725e..dd144e6 100644
--- a/pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart.strong.expect
+++ b/pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart.strong.expect
@@ -11,48 +11,48 @@
     return null;
 }
 static method test() → dynamic {
-  self::takeIII(let final dynamic #t1 = math::max in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:16:16: Error: A value of type '<T extends dart.core::num>(dart.math::max::T, dart.math::max::T) \u8594 dart.math::max::T' can't be assigned to a variable of type '(dart.core::int, dart.core::int) \u8594 dart.core::int'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::int, dart.core::int) \u8594 dart.core::int'.\n  takeIII(math.max);\n               ^")));
-  self::takeDDD(let final dynamic #t2 = math::max in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:17:16: Error: A value of type '<T extends dart.core::num>(dart.math::max::T, dart.math::max::T) \u8594 dart.math::max::T' can't be assigned to a variable of type '(dart.core::double, dart.core::double) \u8594 dart.core::double'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::double, dart.core::double) \u8594 dart.core::double'.\n  takeDDD(math.max);\n               ^")));
-  self::takeNNN(let final dynamic #t3 = math::max in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:18:16: Error: A value of type '<T extends dart.core::num>(dart.math::max::T, dart.math::max::T) \u8594 dart.math::max::T' can't be assigned to a variable of type '(dart.core::num, dart.core::num) \u8594 dart.core::num'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::num, dart.core::num) \u8594 dart.core::num'.\n  takeNNN(math.max);\n               ^")));
-  self::takeIDN(let final dynamic #t4 = math::max in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:19:16: Error: A value of type '<T extends dart.core::num>(dart.math::max::T, dart.math::max::T) \u8594 dart.math::max::T' can't be assigned to a variable of type '(dart.core::double, dart.core::int) \u8594 dart.core::num'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::double, dart.core::int) \u8594 dart.core::num'.\n  takeIDN(math.max);\n               ^")));
-  self::takeDIN(let final dynamic #t5 = math::max in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:20:16: Error: A value of type '<T extends dart.core::num>(dart.math::max::T, dart.math::max::T) \u8594 dart.math::max::T' can't be assigned to a variable of type '(dart.core::int, dart.core::double) \u8594 dart.core::num'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::int, dart.core::double) \u8594 dart.core::num'.\n  takeDIN(math.max);\n               ^")));
-  self::takeIIN(let final dynamic #t6 = math::max in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:21:16: Error: A value of type '<T extends dart.core::num>(dart.math::max::T, dart.math::max::T) \u8594 dart.math::max::T' can't be assigned to a variable of type '(dart.core::int, dart.core::int) \u8594 dart.core::num'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::int, dart.core::int) \u8594 dart.core::num'.\n  takeIIN(math.max);\n               ^")));
-  self::takeDDN(let final dynamic #t7 = math::max in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:22:16: Error: A value of type '<T extends dart.core::num>(dart.math::max::T, dart.math::max::T) \u8594 dart.math::max::T' can't be assigned to a variable of type '(dart.core::double, dart.core::double) \u8594 dart.core::num'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::double, dart.core::double) \u8594 dart.core::num'.\n  takeDDN(math.max);\n               ^")));
-  self::takeIIO(let final dynamic #t8 = math::max in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:23:16: Error: A value of type '<T extends dart.core::num>(dart.math::max::T, dart.math::max::T) \u8594 dart.math::max::T' can't be assigned to a variable of type '(dart.core::int, dart.core::int) \u8594 dart.core::Object'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::int, dart.core::int) \u8594 dart.core::Object'.\n  takeIIO(math.max);\n               ^")));
-  self::takeDDO(let final dynamic #t9 = math::max in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:24:16: Error: A value of type '<T extends dart.core::num>(dart.math::max::T, dart.math::max::T) \u8594 dart.math::max::T' can't be assigned to a variable of type '(dart.core::double, dart.core::double) \u8594 dart.core::Object'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::double, dart.core::double) \u8594 dart.core::Object'.\n  takeDDO(math.max);\n               ^")));
-  self::takeOOI(let final dynamic #t10 = math::max in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:26:70: Error: A value of type '<T extends dart.core::num>(dart.math::max::T, dart.math::max::T) \u8594 dart.math::max::T' can't be assigned to a variable of type '(dart.core::Object, dart.core::Object) \u8594 dart.core::int'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::Object, dart.core::Object) \u8594 dart.core::int'.\n  takeOOI(/*error:COULD_NOT_INFER,error:INVALID_CAST_FUNCTION*/ math.max);\n                                                                     ^")));
-  self::takeIDI(let final dynamic #t11 = math::max in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:28:73: Error: A value of type '<T extends dart.core::num>(dart.math::max::T, dart.math::max::T) \u8594 dart.math::max::T' can't be assigned to a variable of type '(dart.core::double, dart.core::int) \u8594 dart.core::int'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::double, dart.core::int) \u8594 dart.core::int'.\n      /*error:COULD_NOT_INFER,error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/ math.max);\n                                                                        ^")));
-  self::takeDID(let final dynamic #t12 = math::max in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:30:73: Error: A value of type '<T extends dart.core::num>(dart.math::max::T, dart.math::max::T) \u8594 dart.math::max::T' can't be assigned to a variable of type '(dart.core::int, dart.core::double) \u8594 dart.core::double'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::int, dart.core::double) \u8594 dart.core::double'.\n      /*error:COULD_NOT_INFER,error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/ math.max);\n                                                                        ^")));
-  self::takeOON(let final dynamic #t13 = math::max in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:31:70: Error: A value of type '<T extends dart.core::num>(dart.math::max::T, dart.math::max::T) \u8594 dart.math::max::T' can't be assigned to a variable of type '(dart.core::Object, dart.core::Object) \u8594 dart.core::num'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::Object, dart.core::Object) \u8594 dart.core::num'.\n  takeOON(/*error:COULD_NOT_INFER,error:INVALID_CAST_FUNCTION*/ math.max);\n                                                                     ^")));
-  self::takeOOO(let final dynamic #t14 = math::max in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:32:70: Error: A value of type '<T extends dart.core::num>(dart.math::max::T, dart.math::max::T) \u8594 dart.math::max::T' can't be assigned to a variable of type '(dart.core::Object, dart.core::Object) \u8594 dart.core::num'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::Object, dart.core::Object) \u8594 dart.core::num'.\n  takeOOO(/*error:COULD_NOT_INFER,error:INVALID_CAST_FUNCTION*/ math.max);\n                                                                     ^")));
-  self::takeIII(let final dynamic #t15 = math::min in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:35:11: Error: A value of type '<T extends dart.core::num>(dart.math::min::T, dart.math::min::T) \u8594 dart.math::min::T' can't be assigned to a variable of type '(dart.core::int, dart.core::int) \u8594 dart.core::int'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::int, dart.core::int) \u8594 dart.core::int'.\n  takeIII(min);\n          ^")));
-  self::takeDDD(let final dynamic #t16 = math::min in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:36:11: Error: A value of type '<T extends dart.core::num>(dart.math::min::T, dart.math::min::T) \u8594 dart.math::min::T' can't be assigned to a variable of type '(dart.core::double, dart.core::double) \u8594 dart.core::double'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::double, dart.core::double) \u8594 dart.core::double'.\n  takeDDD(min);\n          ^")));
-  self::takeNNN(let final dynamic #t17 = math::min in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:37:11: Error: A value of type '<T extends dart.core::num>(dart.math::min::T, dart.math::min::T) \u8594 dart.math::min::T' can't be assigned to a variable of type '(dart.core::num, dart.core::num) \u8594 dart.core::num'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::num, dart.core::num) \u8594 dart.core::num'.\n  takeNNN(min);\n          ^")));
-  self::takeIDN(let final dynamic #t18 = math::min in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:38:11: Error: A value of type '<T extends dart.core::num>(dart.math::min::T, dart.math::min::T) \u8594 dart.math::min::T' can't be assigned to a variable of type '(dart.core::double, dart.core::int) \u8594 dart.core::num'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::double, dart.core::int) \u8594 dart.core::num'.\n  takeIDN(min);\n          ^")));
-  self::takeDIN(let final dynamic #t19 = math::min in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:39:11: Error: A value of type '<T extends dart.core::num>(dart.math::min::T, dart.math::min::T) \u8594 dart.math::min::T' can't be assigned to a variable of type '(dart.core::int, dart.core::double) \u8594 dart.core::num'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::int, dart.core::double) \u8594 dart.core::num'.\n  takeDIN(min);\n          ^")));
-  self::takeIIN(let final dynamic #t20 = math::min in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:40:11: Error: A value of type '<T extends dart.core::num>(dart.math::min::T, dart.math::min::T) \u8594 dart.math::min::T' can't be assigned to a variable of type '(dart.core::int, dart.core::int) \u8594 dart.core::num'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::int, dart.core::int) \u8594 dart.core::num'.\n  takeIIN(min);\n          ^")));
-  self::takeDDN(let final dynamic #t21 = math::min in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:41:11: Error: A value of type '<T extends dart.core::num>(dart.math::min::T, dart.math::min::T) \u8594 dart.math::min::T' can't be assigned to a variable of type '(dart.core::double, dart.core::double) \u8594 dart.core::num'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::double, dart.core::double) \u8594 dart.core::num'.\n  takeDDN(min);\n          ^")));
-  self::takeIIO(let final dynamic #t22 = math::min in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:42:11: Error: A value of type '<T extends dart.core::num>(dart.math::min::T, dart.math::min::T) \u8594 dart.math::min::T' can't be assigned to a variable of type '(dart.core::int, dart.core::int) \u8594 dart.core::Object'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::int, dart.core::int) \u8594 dart.core::Object'.\n  takeIIO(min);\n          ^")));
-  self::takeDDO(let final dynamic #t23 = math::min in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:43:11: Error: A value of type '<T extends dart.core::num>(dart.math::min::T, dart.math::min::T) \u8594 dart.math::min::T' can't be assigned to a variable of type '(dart.core::double, dart.core::double) \u8594 dart.core::Object'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::double, dart.core::double) \u8594 dart.core::Object'.\n  takeDDO(min);\n          ^")));
-  self::takeOOI(let final dynamic #t24 = math::min in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:45:65: Error: A value of type '<T extends dart.core::num>(dart.math::min::T, dart.math::min::T) \u8594 dart.math::min::T' can't be assigned to a variable of type '(dart.core::Object, dart.core::Object) \u8594 dart.core::int'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::Object, dart.core::Object) \u8594 dart.core::int'.\n  takeOOI(/*error:COULD_NOT_INFER,error:INVALID_CAST_FUNCTION*/ min);\n                                                                ^")));
-  self::takeIDI(let final dynamic #t25 = math::min in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:46:72: Error: A value of type '<T extends dart.core::num>(dart.math::min::T, dart.math::min::T) \u8594 dart.math::min::T' can't be assigned to a variable of type '(dart.core::double, dart.core::int) \u8594 dart.core::int'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::double, dart.core::int) \u8594 dart.core::int'.\n  takeIDI(/*error:COULD_NOT_INFER,error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/ min);\n                                                                       ^")));
-  self::takeDID(let final dynamic #t26 = math::min in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:47:72: Error: A value of type '<T extends dart.core::num>(dart.math::min::T, dart.math::min::T) \u8594 dart.math::min::T' can't be assigned to a variable of type '(dart.core::int, dart.core::double) \u8594 dart.core::double'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::int, dart.core::double) \u8594 dart.core::double'.\n  takeDID(/*error:COULD_NOT_INFER,error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/ min);\n                                                                       ^")));
-  self::takeOON(let final dynamic #t27 = math::min in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:48:65: Error: A value of type '<T extends dart.core::num>(dart.math::min::T, dart.math::min::T) \u8594 dart.math::min::T' can't be assigned to a variable of type '(dart.core::Object, dart.core::Object) \u8594 dart.core::num'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::Object, dart.core::Object) \u8594 dart.core::num'.\n  takeOON(/*error:COULD_NOT_INFER,error:INVALID_CAST_FUNCTION*/ min);\n                                                                ^")));
-  self::takeOOO(let final dynamic #t28 = math::min in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:49:65: Error: A value of type '<T extends dart.core::num>(dart.math::min::T, dart.math::min::T) \u8594 dart.math::min::T' can't be assigned to a variable of type '(dart.core::Object, dart.core::Object) \u8594 dart.core::num'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::Object, dart.core::Object) \u8594 dart.core::num'.\n  takeOOO(/*error:COULD_NOT_INFER,error:INVALID_CAST_FUNCTION*/ min);\n                                                                ^")));
-  self::takeIII(let final dynamic #t29 = new self::C::•().{self::C::m} in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:52:37: Error: A value of type '<T extends dart.core::num>(test::C::m::T, test::C::m::T) \u8594 test::C::m::T' can't be assigned to a variable of type '(dart.core::int, dart.core::int) \u8594 dart.core::int'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::int, dart.core::int) \u8594 dart.core::int'.\n  takeIII(new C(). /*@target=C::m*/ m);\n                                    ^")));
-  self::takeDDD(let final dynamic #t30 = new self::C::•().{self::C::m} in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:53:37: Error: A value of type '<T extends dart.core::num>(test::C::m::T, test::C::m::T) \u8594 test::C::m::T' can't be assigned to a variable of type '(dart.core::double, dart.core::double) \u8594 dart.core::double'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::double, dart.core::double) \u8594 dart.core::double'.\n  takeDDD(new C(). /*@target=C::m*/ m);\n                                    ^")));
-  self::takeNNN(let final dynamic #t31 = new self::C::•().{self::C::m} in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:54:37: Error: A value of type '<T extends dart.core::num>(test::C::m::T, test::C::m::T) \u8594 test::C::m::T' can't be assigned to a variable of type '(dart.core::num, dart.core::num) \u8594 dart.core::num'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::num, dart.core::num) \u8594 dart.core::num'.\n  takeNNN(new C(). /*@target=C::m*/ m);\n                                    ^")));
-  self::takeIDN(let final dynamic #t32 = new self::C::•().{self::C::m} in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:55:37: Error: A value of type '<T extends dart.core::num>(test::C::m::T, test::C::m::T) \u8594 test::C::m::T' can't be assigned to a variable of type '(dart.core::double, dart.core::int) \u8594 dart.core::num'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::double, dart.core::int) \u8594 dart.core::num'.\n  takeIDN(new C(). /*@target=C::m*/ m);\n                                    ^")));
-  self::takeDIN(let final dynamic #t33 = new self::C::•().{self::C::m} in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:56:37: Error: A value of type '<T extends dart.core::num>(test::C::m::T, test::C::m::T) \u8594 test::C::m::T' can't be assigned to a variable of type '(dart.core::int, dart.core::double) \u8594 dart.core::num'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::int, dart.core::double) \u8594 dart.core::num'.\n  takeDIN(new C(). /*@target=C::m*/ m);\n                                    ^")));
-  self::takeIIN(let final dynamic #t34 = new self::C::•().{self::C::m} in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:57:37: Error: A value of type '<T extends dart.core::num>(test::C::m::T, test::C::m::T) \u8594 test::C::m::T' can't be assigned to a variable of type '(dart.core::int, dart.core::int) \u8594 dart.core::num'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::int, dart.core::int) \u8594 dart.core::num'.\n  takeIIN(new C(). /*@target=C::m*/ m);\n                                    ^")));
-  self::takeDDN(let final dynamic #t35 = new self::C::•().{self::C::m} in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:58:37: Error: A value of type '<T extends dart.core::num>(test::C::m::T, test::C::m::T) \u8594 test::C::m::T' can't be assigned to a variable of type '(dart.core::double, dart.core::double) \u8594 dart.core::num'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::double, dart.core::double) \u8594 dart.core::num'.\n  takeDDN(new C(). /*@target=C::m*/ m);\n                                    ^")));
-  self::takeIIO(let final dynamic #t36 = new self::C::•().{self::C::m} in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:59:37: Error: A value of type '<T extends dart.core::num>(test::C::m::T, test::C::m::T) \u8594 test::C::m::T' can't be assigned to a variable of type '(dart.core::int, dart.core::int) \u8594 dart.core::Object'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::int, dart.core::int) \u8594 dart.core::Object'.\n  takeIIO(new C(). /*@target=C::m*/ m);\n                                    ^")));
-  self::takeDDO(let final dynamic #t37 = new self::C::•().{self::C::m} in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:60:37: Error: A value of type '<T extends dart.core::num>(test::C::m::T, test::C::m::T) \u8594 test::C::m::T' can't be assigned to a variable of type '(dart.core::double, dart.core::double) \u8594 dart.core::Object'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::double, dart.core::double) \u8594 dart.core::Object'.\n  takeDDO(new C(). /*@target=C::m*/ m);\n                                    ^")));
-  self::takeOON(let final dynamic #t38 = new self::C::•().{self::C::m} in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:73:26: Error: A value of type '<T extends dart.core::num>(test::C::m::T, test::C::m::T) \u8594 test::C::m::T' can't be assigned to a variable of type '(dart.core::Object, dart.core::Object) \u8594 dart.core::num'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::Object, dart.core::Object) \u8594 dart.core::num'.\n      . /*@target=C::m*/ m);\n                         ^")));
-  self::takeOOO(let final dynamic #t39 = new self::C::•().{self::C::m} in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:75:26: Error: A value of type '<T extends dart.core::num>(test::C::m::T, test::C::m::T) \u8594 test::C::m::T' can't be assigned to a variable of type '(dart.core::Object, dart.core::Object) \u8594 dart.core::num'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::Object, dart.core::Object) \u8594 dart.core::num'.\n      . /*@target=C::m*/ m);\n                         ^")));
-  self::takeOOI(let final dynamic #t40 = new self::C::•().{self::C::m} in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:82:26: Error: A value of type '<T extends dart.core::num>(test::C::m::T, test::C::m::T) \u8594 test::C::m::T' can't be assigned to a variable of type '(dart.core::Object, dart.core::Object) \u8594 dart.core::int'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::Object, dart.core::Object) \u8594 dart.core::int'.\n      . /*@target=C::m*/ m);\n                         ^")));
-  self::takeIDI(let final dynamic #t41 = new self::C::•().{self::C::m} in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:86:30: Error: A value of type '<T extends dart.core::num>(test::C::m::T, test::C::m::T) \u8594 test::C::m::T' can't be assigned to a variable of type '(dart.core::double, dart.core::int) \u8594 dart.core::int'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::double, dart.core::int) \u8594 dart.core::int'.\n          . /*@target=C::m*/ m);\n                             ^")));
-  self::takeDID(let final dynamic #t42 = new self::C::•().{self::C::m} in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:89:30: Error: A value of type '<T extends dart.core::num>(test::C::m::T, test::C::m::T) \u8594 test::C::m::T' can't be assigned to a variable of type '(dart.core::int, dart.core::double) \u8594 dart.core::double'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::int, dart.core::double) \u8594 dart.core::double'.\n          . /*@target=C::m*/ m);\n                             ^")));
+  self::takeIII(math::max<core::int>);
+  self::takeDDD(math::max<core::double>);
+  self::takeNNN(math::max<core::num>);
+  self::takeIDN(math::max<core::num>);
+  self::takeDIN(math::max<core::num>);
+  self::takeIIN(math::max<core::int>);
+  self::takeDDN(math::max<core::double>);
+  self::takeIIO(math::max<core::int>);
+  self::takeDDO(math::max<core::double>);
+  self::takeOOI((math::max<core::Object>) as{TypeError} (core::Object, core::Object) → core::int);
+  self::takeIDI(let final dynamic #t1 = math::max<core::num> in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:28:73: Error: A value of type '(dart.core::num, dart.core::num) \u8594 dart.core::num' can't be assigned to a variable of type '(dart.core::double, dart.core::int) \u8594 dart.core::int'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::double, dart.core::int) \u8594 dart.core::int'.\n      /*error:COULD_NOT_INFER,error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/ math.max);\n                                                                        ^")));
+  self::takeDID(let final dynamic #t2 = math::max<core::num> in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:30:73: Error: A value of type '(dart.core::num, dart.core::num) \u8594 dart.core::num' can't be assigned to a variable of type '(dart.core::int, dart.core::double) \u8594 dart.core::double'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::int, dart.core::double) \u8594 dart.core::double'.\n      /*error:COULD_NOT_INFER,error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/ math.max);\n                                                                        ^")));
+  self::takeOON((math::max<core::Object>) as{TypeError} (core::Object, core::Object) → core::num);
+  self::takeOOO((math::max<core::Object>) as{TypeError} (core::Object, core::Object) → core::num);
+  self::takeIII(math::min<core::int>);
+  self::takeDDD(math::min<core::double>);
+  self::takeNNN(math::min<core::num>);
+  self::takeIDN(math::min<core::num>);
+  self::takeDIN(math::min<core::num>);
+  self::takeIIN(math::min<core::int>);
+  self::takeDDN(math::min<core::double>);
+  self::takeIIO(math::min<core::int>);
+  self::takeDDO(math::min<core::double>);
+  self::takeOOI((math::min<core::Object>) as{TypeError} (core::Object, core::Object) → core::int);
+  self::takeIDI(let final dynamic #t3 = math::min<core::num> in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:46:72: Error: A value of type '(dart.core::num, dart.core::num) \u8594 dart.core::num' can't be assigned to a variable of type '(dart.core::double, dart.core::int) \u8594 dart.core::int'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::double, dart.core::int) \u8594 dart.core::int'.\n  takeIDI(/*error:COULD_NOT_INFER,error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/ min);\n                                                                       ^")));
+  self::takeDID(let final dynamic #t4 = math::min<core::num> in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:47:72: Error: A value of type '(dart.core::num, dart.core::num) \u8594 dart.core::num' can't be assigned to a variable of type '(dart.core::int, dart.core::double) \u8594 dart.core::double'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::int, dart.core::double) \u8594 dart.core::double'.\n  takeDID(/*error:COULD_NOT_INFER,error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/ min);\n                                                                       ^")));
+  self::takeOON((math::min<core::Object>) as{TypeError} (core::Object, core::Object) → core::num);
+  self::takeOOO((math::min<core::Object>) as{TypeError} (core::Object, core::Object) → core::num);
+  self::takeIII(new self::C::•().{self::C::m}<core::int>);
+  self::takeDDD(new self::C::•().{self::C::m}<core::double>);
+  self::takeNNN(new self::C::•().{self::C::m}<core::num>);
+  self::takeIDN(new self::C::•().{self::C::m}<core::num>);
+  self::takeDIN(new self::C::•().{self::C::m}<core::num>);
+  self::takeIIN(new self::C::•().{self::C::m}<core::int>);
+  self::takeDDN(new self::C::•().{self::C::m}<core::double>);
+  self::takeIIO(new self::C::•().{self::C::m}<core::int>);
+  self::takeDDO(new self::C::•().{self::C::m}<core::double>);
+  self::takeOON((new self::C::•().{self::C::m}<core::Object>) as{TypeError} (core::Object, core::Object) → core::num);
+  self::takeOOO((new self::C::•().{self::C::m}<core::Object>) as{TypeError} (core::Object, core::Object) → core::num);
+  self::takeOOI((new self::C::•().{self::C::m}<core::Object>) as{TypeError} (core::Object, core::Object) → core::int);
+  self::takeIDI(let final dynamic #t5 = new self::C::•().{self::C::m}<core::num> in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:86:30: Error: A value of type '(dart.core::num, dart.core::num) \u8594 dart.core::num' can't be assigned to a variable of type '(dart.core::double, dart.core::int) \u8594 dart.core::int'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::double, dart.core::int) \u8594 dart.core::int'.\n          . /*@target=C::m*/ m);\n                             ^")));
+  self::takeDID(let final dynamic #t6 = new self::C::•().{self::C::m}<core::num> in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart:89:30: Error: A value of type '(dart.core::num, dart.core::num) \u8594 dart.core::num' can't be assigned to a variable of type '(dart.core::int, dart.core::double) \u8594 dart.core::double'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::int, dart.core::double) \u8594 dart.core::double'.\n          . /*@target=C::m*/ m);\n                             ^")));
 }
 static method takeIII((core::int, core::int) → core::int fn) → void {}
 static method takeDDD((core::double, core::double) → core::double fn) → void {}
diff --git a/pkg/front_end/testcases/inference/generic_methods_nested_generic_instantiation.dart.strong.expect b/pkg/front_end/testcases/inference/generic_methods_nested_generic_instantiation.dart.strong.expect
index 703cafd..341eac6 100644
--- a/pkg/front_end/testcases/inference/generic_methods_nested_generic_instantiation.dart.strong.expect
+++ b/pkg/front_end/testcases/inference/generic_methods_nested_generic_instantiation.dart.strong.expect
@@ -18,6 +18,6 @@
 static method main() → dynamic {
   core::List<self::Trace> traces = <self::Trace>[];
   core::int longest = traces.{core::Iterable::map}<core::int>((self::Trace trace) → core::int {
-    return trace.{self::Trace::frames}.{core::Iterable::map}<core::int>((self::Frame frame) → core::int => frame.{self::Frame::location}.{core::String::length}).{core::Iterable::fold}<core::int>(0, let final dynamic #t1 = math::max in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_nested_generic_instantiation.dart:28:69: Error: A value of type '<T extends dart.core::num>(dart.math::max::T, dart.math::max::T) \u8594 dart.math::max::T' can't be assigned to a variable of type '(dart.core::int, dart.core::int) \u8594 dart.core::int'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::int, dart.core::int) \u8594 dart.core::int'.\n        . /*@typeArgs=int*/ /*@target=Iterable::fold*/ fold(0, math.max);\n                                                                    ^")));
-  }).{core::Iterable::fold}<core::int>(0, let final dynamic #t2 = math::max in let dynamic _ = null in const core::_ConstantExpressionError::•().{core::_ConstantExpressionError::_throw}(new core::_CompileTimeError::•("pkg/front_end/testcases/inference/generic_methods_nested_generic_instantiation.dart:29:65: Error: A value of type '<T extends dart.core::num>(dart.math::max::T, dart.math::max::T) \u8594 dart.math::max::T' can't be assigned to a variable of type '(dart.core::int, dart.core::int) \u8594 dart.core::int'.\nTry changing the type of the left hand side, or casting the right hand side to '(dart.core::int, dart.core::int) \u8594 dart.core::int'.\n  }). /*@typeArgs=int*/ /*@target=Iterable::fold*/ fold(0, math.max);\n                                                                ^")));
+    return trace.{self::Trace::frames}.{core::Iterable::map}<core::int>((self::Frame frame) → core::int => frame.{self::Frame::location}.{core::String::length}).{core::Iterable::fold}<core::int>(0, math::max<core::int>);
+  }).{core::Iterable::fold}<core::int>(0, math::max<core::int>);
 }
diff --git a/pkg/front_end/testcases/inference/instantiate_tearoff.dart b/pkg/front_end/testcases/inference/instantiate_tearoff.dart
new file mode 100644
index 0000000..10eeb1f
--- /dev/null
+++ b/pkg/front_end/testcases/inference/instantiate_tearoff.dart
@@ -0,0 +1,31 @@
+// Copyright (c) 2017, the Dart project authors.  Please see the AUTHORS file
+// 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.
+
+/*@testedFeatures=inference*/
+library test;
+
+T f<T>(T x) => x;
+
+class C {
+  T f<T>(T x) => x;
+  static T g<T>(T x) => x;
+}
+
+class D extends C {
+  void test() {
+    int Function(int) func;
+    func = super. /*@target=C::f*/ f;
+  }
+}
+
+void test() {
+  T h<T>(T x) => x;
+  int Function(int) func;
+  func = f;
+  func = new C(). /*@target=C::f*/ f;
+  func = C.g;
+  func = h;
+}
+
+main() {}
diff --git a/pkg/front_end/testcases/inference/instantiate_tearoff.dart.direct.expect b/pkg/front_end/testcases/inference/instantiate_tearoff.dart.direct.expect
new file mode 100644
index 0000000..47f329d
--- /dev/null
+++ b/pkg/front_end/testcases/inference/instantiate_tearoff.dart.direct.expect
@@ -0,0 +1,34 @@
+library test;
+import self as self;
+import "dart:core" as core;
+
+class C extends core::Object {
+  default constructor •() → void
+    : super core::Object::•()
+    ;
+  method f<T extends core::Object>(self::C::f::T x) → self::C::f::T
+    return x;
+  static method g<T extends core::Object>(self::C::g::T x) → self::C::g::T
+    return x;
+}
+class D extends self::C {
+  default constructor •() → void
+    : super self::C::•()
+    ;
+  method test() → void {
+    (core::int) → core::int func;
+    func = super.{self::C::f};
+  }
+}
+static method f<T extends core::Object>(self::f::T x) → self::f::T
+  return x;
+static method test() → void {
+  function h<T extends core::Object>(T x) → T
+    return x;
+  (core::int) → core::int func;
+  func = self::f;
+  func = new self::C::•().f;
+  func = self::C::g;
+  func = h;
+}
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/inference/instantiate_tearoff.dart.outline.expect b/pkg/front_end/testcases/inference/instantiate_tearoff.dart.outline.expect
new file mode 100644
index 0000000..c14cfbd
--- /dev/null
+++ b/pkg/front_end/testcases/inference/instantiate_tearoff.dart.outline.expect
@@ -0,0 +1,24 @@
+library test;
+import self as self;
+import "dart:core" as core;
+
+class C extends core::Object {
+  default constructor •() → void
+    ;
+  method f<T extends core::Object>(self::C::f::T x) → self::C::f::T
+    ;
+  static method g<T extends core::Object>(self::C::g::T x) → self::C::g::T
+    ;
+}
+class D extends self::C {
+  default constructor •() → void
+    ;
+  method test() → void
+    ;
+}
+static method f<T extends core::Object>(self::f::T x) → self::f::T
+  ;
+static method test() → void
+  ;
+static method main() → dynamic
+  ;
diff --git a/pkg/front_end/testcases/inference/instantiate_tearoff.dart.strong.expect b/pkg/front_end/testcases/inference/instantiate_tearoff.dart.strong.expect
new file mode 100644
index 0000000..c6f2f60
--- /dev/null
+++ b/pkg/front_end/testcases/inference/instantiate_tearoff.dart.strong.expect
@@ -0,0 +1,34 @@
+library test;
+import self as self;
+import "dart:core" as core;
+
+class C extends core::Object {
+  default constructor •() → void
+    : super core::Object::•()
+    ;
+  method f<T extends core::Object>(self::C::f::T x) → self::C::f::T
+    return x;
+  static method g<T extends core::Object>(self::C::g::T x) → self::C::g::T
+    return x;
+}
+class D extends self::C {
+  default constructor •() → void
+    : super self::C::•()
+    ;
+  method test() → void {
+    (core::int) → core::int func;
+    func = super.{self::C::f}<core::int>;
+  }
+}
+static method f<T extends core::Object>(self::f::T x) → self::f::T
+  return x;
+static method test() → void {
+  function h<T extends core::Object>(T x) → T
+    return x;
+  (core::int) → core::int func;
+  func = self::f<core::int>;
+  func = new self::C::•().{self::C::f}<core::int>;
+  func = self::C::g<core::int>;
+  func = h<core::int>;
+}
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/inference/instantiate_tearoff_after_contravariance_check.dart b/pkg/front_end/testcases/inference/instantiate_tearoff_after_contravariance_check.dart
new file mode 100644
index 0000000..d272786
--- /dev/null
+++ b/pkg/front_end/testcases/inference/instantiate_tearoff_after_contravariance_check.dart
@@ -0,0 +1,18 @@
+// Copyright (c) 2017, the Dart project authors.  Please see the AUTHORS file
+// 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.
+
+/*@testedFeatures=inference*/
+library test;
+
+class C<T> {
+  void Function(T) f<U>(U x) => /*@returnType=Null*/ (/*@type=C::T*/ y) {};
+}
+
+void test(C<String> c) {
+  // Tear-off of c.f needs to be type checked due to contravariance.  The
+  // instantiation should occur after the type check.
+  void Function(String) Function(int) tearoff = c. /*@target=C::f*/ f;
+}
+
+main() {}
diff --git a/pkg/front_end/testcases/inference/instantiate_tearoff_after_contravariance_check.dart.direct.expect b/pkg/front_end/testcases/inference/instantiate_tearoff_after_contravariance_check.dart.direct.expect
new file mode 100644
index 0000000..aee70c3
--- /dev/null
+++ b/pkg/front_end/testcases/inference/instantiate_tearoff_after_contravariance_check.dart.direct.expect
@@ -0,0 +1,15 @@
+library test;
+import self as self;
+import "dart:core" as core;
+
+class C<T extends core::Object> extends core::Object {
+  default constructor •() → void
+    : super core::Object::•()
+    ;
+  method f<U extends core::Object>(self::C::f::U x) → (self::C::T) → void
+    return (dynamic y) → dynamic {};
+}
+static method test(self::C<core::String> c) → void {
+  (core::int) → (core::String) → void tearoff = c.f;
+}
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/inference/instantiate_tearoff_after_contravariance_check.dart.outline.expect b/pkg/front_end/testcases/inference/instantiate_tearoff_after_contravariance_check.dart.outline.expect
new file mode 100644
index 0000000..5b4814c
--- /dev/null
+++ b/pkg/front_end/testcases/inference/instantiate_tearoff_after_contravariance_check.dart.outline.expect
@@ -0,0 +1,14 @@
+library test;
+import self as self;
+import "dart:core" as core;
+
+class C<T extends core::Object> extends core::Object {
+  default constructor •() → void
+    ;
+  method f<U extends core::Object>(self::C::f::U x) → (self::C::T) → void
+    ;
+}
+static method test(self::C<core::String> c) → void
+  ;
+static method main() → dynamic
+  ;
diff --git a/pkg/front_end/testcases/inference/instantiate_tearoff_after_contravariance_check.dart.strong.expect b/pkg/front_end/testcases/inference/instantiate_tearoff_after_contravariance_check.dart.strong.expect
new file mode 100644
index 0000000..fb13da1
--- /dev/null
+++ b/pkg/front_end/testcases/inference/instantiate_tearoff_after_contravariance_check.dart.strong.expect
@@ -0,0 +1,15 @@
+library test;
+import self as self;
+import "dart:core" as core;
+
+class C<T extends core::Object> extends core::Object {
+  default constructor •() → void
+    : super core::Object::•()
+    ;
+  generic-contravariant method f<U extends core::Object>(self::C::f::U x) → (self::C::T) → void
+    return (self::C::T y) → core::Null {};
+}
+static method test(self::C<core::String> c) → void {
+  (core::int) → (core::String) → void tearoff = c.{self::C::f} as{TypeError} <U extends core::Object>(U) → (core::String) → void<core::int>;
+}
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/inference/instantiate_tearoff_of_call.dart b/pkg/front_end/testcases/inference/instantiate_tearoff_of_call.dart
new file mode 100644
index 0000000..1967387
--- /dev/null
+++ b/pkg/front_end/testcases/inference/instantiate_tearoff_of_call.dart
@@ -0,0 +1,13 @@
+// Copyright (c) 2017, the Dart project authors.  Please see the AUTHORS file
+// 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.
+
+/*@testedFeatures=inference*/
+library test;
+
+void test(T Function<T>(T) f) {
+  int Function(int) func;
+  func = f.call;
+}
+
+main() {}
diff --git a/pkg/front_end/testcases/inference/instantiate_tearoff_of_call.dart.direct.expect b/pkg/front_end/testcases/inference/instantiate_tearoff_of_call.dart.direct.expect
new file mode 100644
index 0000000..258ba0e
--- /dev/null
+++ b/pkg/front_end/testcases/inference/instantiate_tearoff_of_call.dart.direct.expect
@@ -0,0 +1,9 @@
+library test;
+import self as self;
+import "dart:core" as core;
+
+static method test(<T extends core::Object>(T) → T f) → void {
+  (core::int) → core::int func;
+  func = f.call;
+}
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/inference/instantiate_tearoff_of_call.dart.outline.expect b/pkg/front_end/testcases/inference/instantiate_tearoff_of_call.dart.outline.expect
new file mode 100644
index 0000000..65e10ba
--- /dev/null
+++ b/pkg/front_end/testcases/inference/instantiate_tearoff_of_call.dart.outline.expect
@@ -0,0 +1,8 @@
+library test;
+import self as self;
+import "dart:core" as core;
+
+static method test(<T extends core::Object>(T) → T f) → void
+  ;
+static method main() → dynamic
+  ;
diff --git a/pkg/front_end/testcases/inference/instantiate_tearoff_of_call.dart.strong.expect b/pkg/front_end/testcases/inference/instantiate_tearoff_of_call.dart.strong.expect
new file mode 100644
index 0000000..c944bdb
--- /dev/null
+++ b/pkg/front_end/testcases/inference/instantiate_tearoff_of_call.dart.strong.expect
@@ -0,0 +1,9 @@
+library test;
+import self as self;
+import "dart:core" as core;
+
+static method test(<T extends core::Object>(T) → T f) → void {
+  (core::int) → core::int func;
+  func = f.call<core::int>;
+}
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/strong.status b/pkg/front_end/testcases/strong.status
index 36cc99b..b92e4f8 100644
--- a/pkg/front_end/testcases/strong.status
+++ b/pkg/front_end/testcases/strong.status
@@ -102,6 +102,7 @@
 inference/infer_type_regardless_of_declaration_order_or_cycles: RuntimeError
 inference/infer_types_on_generic_instantiations_4: RuntimeError
 inference/infer_types_on_generic_instantiations_infer: TypeCheckError
+inference/instantiate_tearoff_of_call: TypeCheckError
 inference/instantiate_to_bounds_generic_has_bound_defined_after transform: RuntimeError
 inference/unresolved_super: TypeCheckError
 inference/unsafe_block_closure_inference_function_call_explicit_dynamic_param_via_expr1: Fail # Issue #25824
diff --git a/pkg/kernel/lib/ast.dart b/pkg/kernel/lib/ast.dart
index 727e85b..e443158 100644
--- a/pkg/kernel/lib/ast.dart
+++ b/pkg/kernel/lib/ast.dart
@@ -2927,7 +2927,7 @@
     FunctionType type = expression.getStaticType(types);
     return Substitution
         .fromPairs(type.typeParameters, typeArguments)
-        .substituteType(type);
+        .substituteType(type.withoutTypeParameters);
   }
 
   accept(ExpressionVisitor v) => v.visitInstantiation(this);
diff --git a/pkg/kernel/lib/type_checker.dart b/pkg/kernel/lib/type_checker.dart
index 6fc16b3..f0d1247 100644
--- a/pkg/kernel/lib/type_checker.dart
+++ b/pkg/kernel/lib/type_checker.dart
@@ -281,18 +281,14 @@
         fail(arguments, 'Too many positional arguments');
         return const BottomType();
       }
-      if (arguments.types.length != typeParameters.length) {
+      var typeArguments = arguments.types;
+      if (typeArguments.length != typeParameters.length) {
         fail(arguments, 'Wrong number of type arguments');
         return const BottomType();
       }
-      var instantiation =
-          Substitution.fromPairs(typeParameters, arguments.types);
-      var substitution = Substitution.combine(receiver, instantiation);
-      for (int i = 0; i < typeParameters.length; ++i) {
-        var argument = arguments.types[i];
-        var bound = substitution.substituteType(typeParameters[i].bound);
-        checkAssignable(arguments, argument, bound);
-      }
+      Substitution substitution = _instantiateFunction(
+          typeParameters, typeArguments, arguments,
+          receiverSubstitution: receiver);
       for (int i = 0; i < arguments.positional.length; ++i) {
         var expectedType = substitution.substituteType(
             functionType.positionalParameters[i],
@@ -385,6 +381,21 @@
     }
   }
 
+  Substitution _instantiateFunction(List<TypeParameter> typeParameters,
+      List<DartType> typeArguments, TreeNode where,
+      {Substitution receiverSubstitution}) {
+    var instantiation = Substitution.fromPairs(typeParameters, typeArguments);
+    var substitution = receiverSubstitution == null
+        ? instantiation
+        : Substitution.combine(receiverSubstitution, instantiation);
+    for (int i = 0; i < typeParameters.length; ++i) {
+      var argument = typeArguments[i];
+      var bound = substitution.substituteType(typeParameters[i].bound);
+      checkAssignable(where, argument, bound);
+    }
+    return substitution;
+  }
+
   @override
   DartType visitAsExpression(AsExpression node) {
     visitExpression(node.operand);
@@ -482,7 +493,7 @@
   DartType visitInstantiation(Instantiation node) {
     DartType type = visitExpression(node.expression);
     if (type is! FunctionType) {
-      fail(node, 'Not a function type');
+      fail(node, 'Not a function type: $type');
       return const BottomType();
     }
     FunctionType functionType = type;
@@ -490,9 +501,9 @@
       fail(node, 'Wrong number of type arguments');
       return const BottomType();
     }
-    return Substitution
-        .fromPairs(functionType.typeParameters, node.typeArguments)
-        .substituteType(functionType);
+    return _instantiateFunction(
+            functionType.typeParameters, node.typeArguments, node)
+        .substituteType(functionType.withoutTypeParameters);
   }
 
   @override
diff --git a/tests/language_2/instantiate_tearoff_after_contravariance_check_test.dart b/tests/language_2/instantiate_tearoff_after_contravariance_check_test.dart
new file mode 100644
index 0000000..cb0fa33
--- /dev/null
+++ b/tests/language_2/instantiate_tearoff_after_contravariance_check_test.dart
@@ -0,0 +1,27 @@
+// Copyright (c) 2017, the Dart project authors.  Please see the AUTHORS file
+// 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.
+
+import "package:expect/expect.dart";
+
+class A {}
+
+class B extends A {}
+
+class C<T> {
+  void Function(T) f<U>(U x) => (y) {};
+}
+
+void test(C<A> cA, C<A> cB) {
+  // Tear-off of c.f needs to be type checked due to contravariance.  The
+  // instantiation should occur after the type check, so if the type is wrong we
+  // should get a type error.
+  void Function(A) Function(int) tearoffOfCA = cA.f;
+  Expect.throwsTypeError(() {
+    void Function(A) Function(int) tearoffOfCB = cB.f;
+  });
+}
+
+main() {
+  test(new C<A>(), new C<B>());
+}
diff --git a/tests/language_2/instantiate_tearoff_of_call_test.dart b/tests/language_2/instantiate_tearoff_of_call_test.dart
new file mode 100644
index 0000000..665a271
--- /dev/null
+++ b/tests/language_2/instantiate_tearoff_of_call_test.dart
@@ -0,0 +1,30 @@
+// Copyright (c) 2017, the Dart project authors.  Please see the AUTHORS file
+// 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.
+
+import "package:expect/expect.dart";
+
+T f<T>(T x) => x;
+
+void test(T Function<T>(T) f) {
+  int Function(int) intFunc = f.call;
+  dynamic intFuncDynamic = intFunc;
+  Expect.isTrue(intFuncDynamic is int Function(int));
+  Expect.isFalse(intFuncDynamic is String Function(String));
+  Expect.equals(intFuncDynamic(1), 1);
+  Expect.throwsTypeError(() {
+    intFuncDynamic('oops');
+  });
+  String Function(String) stringFunc = f.call;
+  dynamic stringFuncDynamic = stringFunc;
+  Expect.isTrue(stringFuncDynamic is String Function(String));
+  Expect.isFalse(stringFuncDynamic is int Function(int));
+  Expect.equals(stringFuncDynamic('hello'), 'hello');
+  Expect.throwsTypeError(() {
+    stringFuncDynamic(1);
+  });
+}
+
+main() {
+  test(f);
+}
diff --git a/tests/language_2/instantiate_tearoff_test.dart b/tests/language_2/instantiate_tearoff_test.dart
new file mode 100644
index 0000000..892be77
--- /dev/null
+++ b/tests/language_2/instantiate_tearoff_test.dart
@@ -0,0 +1,26 @@
+// Copyright (c) 2017, the Dart project authors.  Please see the AUTHORS file
+// 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.
+
+import "package:expect/expect.dart";
+
+T f<T>(T x) => x;
+
+main() {
+  int Function(int) intFunc = f;
+  dynamic intFuncDynamic = intFunc;
+  Expect.isTrue(intFuncDynamic is int Function(int));
+  Expect.isFalse(intFuncDynamic is String Function(String));
+  Expect.equals(intFuncDynamic(1), 1);
+  Expect.throwsTypeError(() {
+    intFuncDynamic('oops');
+  });
+  String Function(String) stringFunc = f;
+  dynamic stringFuncDynamic = stringFunc;
+  Expect.isTrue(stringFuncDynamic is String Function(String));
+  Expect.isFalse(stringFuncDynamic is int Function(int));
+  Expect.equals(stringFuncDynamic('hello'), 'hello');
+  Expect.throwsTypeError(() {
+    stringFuncDynamic(1);
+  });
+}
diff --git a/tests/language_2/language_2_dart2js.status b/tests/language_2/language_2_dart2js.status
index fa2ef1c..465cd64 100644
--- a/tests/language_2/language_2_dart2js.status
+++ b/tests/language_2/language_2_dart2js.status
@@ -1615,6 +1615,9 @@
 implicit_downcast_during_super_initializer_test: RuntimeError
 implicit_downcast_during_yield_star_test: RuntimeError
 implicit_downcast_during_yield_test: RuntimeError
+instantiate_tearoff_after_contravariance_check_test: RuntimeError
+instantiate_tearoff_of_call_test: RuntimeError
+instantiate_tearoff_test: RuntimeError
 invalid_cast_test/01: MissingCompileTimeError
 invalid_cast_test/02: MissingCompileTimeError
 invalid_cast_test/03: MissingCompileTimeError
@@ -3038,6 +3041,9 @@
 if_null_assignment_behavior_test/13: Crash # Issue 23491
 if_null_assignment_behavior_test/14: Crash # Issue 23491
 infinity_test: RuntimeError # Issue 4984
+instantiate_tearoff_after_contravariance_check_test: RuntimeError
+instantiate_tearoff_of_call_test: RuntimeError
+instantiate_tearoff_test: RuntimeError
 integer_division_by_zero_test: RuntimeError # Issue 8301
 invocation_mirror2_test: RuntimeError # Issue 6490 (wrong retval).
 left_shift_test: RuntimeError # Issue 1533
diff --git a/tests/language_2/language_2_dartdevc.status b/tests/language_2/language_2_dartdevc.status
index 3ae5df5..f86090e 100644
--- a/tests/language_2/language_2_dartdevc.status
+++ b/tests/language_2/language_2_dartdevc.status
@@ -60,6 +60,8 @@
 import_core_prefix_test: CompileTimeError
 import_private_test/01: MissingCompileTimeError # Issue 29920
 initializing_formal_final_test: MissingCompileTimeError
+instantiate_tearoff_after_contravariance_check_test: RuntimeError
+instantiate_tearoff_of_call_test: RuntimeError
 interface_test/00: MissingCompileTimeError
 internal_library_test/01: MissingCompileTimeError # Issue 29920
 method_override_test: CompileTimeError # Negative test
@@ -303,7 +305,7 @@
 final_attempt_reinitialization_test/02: Crash
 final_syntax_test/09: Crash
 function_propagation_test: CompileTimeError
-function_subtype_bound_closure7_test: CompileTimeError
+function_subtype_bound_closure7_test: Crash
 function_type/function_type10_test: CompileTimeError
 function_type/function_type11_test: CompileTimeError
 function_type/function_type14_test: CompileTimeError
@@ -374,12 +376,12 @@
 function_type_parameter_negative_test: Fail
 generalized_void_syntax_test: CompileTimeError
 generic_function_bounds_test: CompileTimeError
-generic_function_dcall_test: CompileTimeError
+generic_function_dcall_test: Crash
 generic_methods_bounds_test/01: MissingCompileTimeError
 generic_methods_generic_function_result_test/01: MissingCompileTimeError
 generic_methods_recursive_bound_test/02: MissingCompileTimeError
-generic_methods_tearoff_specialization_test: CompileTimeError
-generic_methods_unused_parameter_test: CompileTimeError
+generic_methods_tearoff_specialization_test: Crash
+generic_methods_unused_parameter_test: Crash
 generic_no_such_method_dispatcher_simple_test: CompileTimeError # Warning: Superclass has no method named 'foo'.
 generic_no_such_method_dispatcher_test: CompileTimeError # Issue 31533
 getter_override2_test/02: MissingCompileTimeError
@@ -396,6 +398,9 @@
 initializing_formal_type_annotation_test/01: MissingCompileTimeError
 initializing_formal_type_annotation_test/02: MissingCompileTimeError
 instance_call_wrong_argument_count_negative_test: Fail
+instantiate_tearoff_after_contravariance_check_test: Crash
+instantiate_tearoff_of_call_test: Crash
+instantiate_tearoff_test: Crash
 invocation_mirror_test: CompileTimeError # Issue 31402 Error: A value of type 'dart.core::int' can't be assigned to a variable of type 'dart.core::Invocation'.
 issue13179_test: CompileTimeError # Issue 31537
 issue18628_2_test/01: MissingCompileTimeError
diff --git a/tests/language_2/language_2_kernel.status b/tests/language_2/language_2_kernel.status
index 2e049ed..6578d02 100644
--- a/tests/language_2/language_2_kernel.status
+++ b/tests/language_2/language_2_kernel.status
@@ -184,9 +184,6 @@
 async_await_syntax_test/c10a: MissingCompileTimeError
 async_await_syntax_test/d08b: MissingCompileTimeError
 async_await_syntax_test/d10a: MissingCompileTimeError
-async_await_test/02: CompileTimeError # Issue 31402 (Invocation arguments)
-async_await_test/03: CompileTimeError # Issue 31402 (Invocation arguments)
-async_await_test/none: CompileTimeError # Issue 31402 (Invocation arguments)
 async_or_generator_return_type_stacktrace_test/01: MissingCompileTimeError
 async_or_generator_return_type_stacktrace_test/02: MissingCompileTimeError
 async_or_generator_return_type_stacktrace_test/03: MissingCompileTimeError
@@ -431,8 +428,8 @@
 deferred_inlined_test: CompileTimeError # KernelVM bug: Deferred loading kernel issue 28335.
 deferred_inlined_test: RuntimeError
 deferred_load_constants_test/none: CompileTimeError # KernelVM bug: Deferred loading kernel issue 28335.
-deferred_load_inval_code_test: CompileTimeError # KernelVM bug: Deferred loading kernel issue 28335.
 deferred_load_inval_code_test: RuntimeError
+deferred_load_inval_code_test: CompileTimeError # KernelVM bug: Deferred loading kernel issue 28335.
 deferred_load_library_wrong_args_test/01: Pass # Passes by mistake. KernelVM bug: Deferred loading kernel issue 28335.
 deferred_load_library_wrong_args_test/none: CompileTimeError # KernelVM bug: Deferred loading kernel issue 28335.
 deferred_load_library_wrong_args_test/none: RuntimeError
@@ -457,8 +454,8 @@
 deferred_static_seperate_test: CompileTimeError # KernelVM bug: Deferred loading kernel issue 28335.
 deferred_static_seperate_test: RuntimeError
 deferred_super_dependency_test/01: Pass # Passes by mistake. KernelVM bug: Deferred loading kernel issue 28335.
-deferred_type_dependency_test/as: CompileTimeError # KernelVM bug: Deferred loading kernel issue 28335.
 deferred_type_dependency_test/as: RuntimeError
+deferred_type_dependency_test/as: CompileTimeError # KernelVM bug: Deferred loading kernel issue 28335.
 deferred_type_dependency_test/is: CompileTimeError # KernelVM bug: Deferred loading kernel issue 28335.
 deferred_type_dependency_test/is: RuntimeError
 deferred_type_dependency_test/none: CompileTimeError # KernelVM bug: Deferred loading kernel issue 28335.
@@ -470,8 +467,8 @@
 dynamic_prefix_core_test/01: MissingCompileTimeError
 dynamic_prefix_core_test/01: RuntimeError # KernelVM bug: Blocked on language issue 29125.
 dynamic_prefix_core_test/none: RuntimeError
-dynamic_test: CompileTimeError # Issue 31402 (Variable declaration)
 dynamic_test: RuntimeError
+dynamic_test: CompileTimeError # Issue 31402 (Variable declaration)
 emit_const_fields_test: CompileTimeError # Issue 31533
 empty_block_case_test: MissingCompileTimeError
 enum_private_test/02: MissingCompileTimeError
@@ -650,8 +647,8 @@
 generic_function_bounds_test: RuntimeError
 generic_function_dcall_test: CompileTimeError
 generic_function_dcall_test: RuntimeError
-generic_function_type_as_type_argument_test/02: MissingCompileTimeError, OK # No type inference
 generic_function_type_as_type_argument_test/02: Pass # For the wrong reason, issue 30931
+generic_function_type_as_type_argument_test/02: MissingCompileTimeError, OK # No type inference
 generic_function_typedef2_test/04: MissingCompileTimeError
 generic_instanceof2_test: RuntimeError
 generic_instanceof_test: RuntimeError
@@ -694,6 +691,9 @@
 initializing_formal_type_annotation_test/01: MissingCompileTimeError
 initializing_formal_type_annotation_test/02: MissingCompileTimeError
 instanceof2_test: RuntimeError
+instantiate_tearoff_after_contravariance_check_test: CompileTimeError
+instantiate_tearoff_of_call_test: CompileTimeError
+instantiate_tearoff_test: CompileTimeError
 int64_literal_test/03: MissingCompileTimeError # http://dartbug.com/31479
 int64_literal_test/30: MissingCompileTimeError # http://dartbug.com/31479
 interface_test/00: MissingCompileTimeError
@@ -1145,8 +1145,6 @@
 unresolved_top_level_method_test: MissingCompileTimeError
 unresolved_top_level_var_test: MissingCompileTimeError
 vm/canonicalization_preserves_deopt_test: CompileTimeError # Issue 31402 (Assert statement)
-vm/causal_async_exception_stack2_test: CompileTimeError # Issue 31402 (Invocation arguments)
-vm/causal_async_exception_stack_test: CompileTimeError # Issue 31402 (Invocation arguments)
 vm/closure_memory_retention_test: Skip # KernelVM bug: Hits OOM
 vm/debug_break_enabled_vm_test/01: CompileTimeError # KernelVM bug: Bad test using extended break syntax.
 vm/debug_break_enabled_vm_test/none: CompileTimeError # KernelVM bug: Bad test using extended break syntax.
@@ -1427,8 +1425,8 @@
 async_star_test/01: CompileTimeError # Issue 2238.
 async_star_test/01: Crash
 async_star_test/01: Pass
-async_star_test/02: RuntimeError
 async_star_test/02: CompileTimeError # Issue 31402 (Invocation arguments)
+async_star_test/02: RuntimeError
 async_star_test/03: CompileTimeError # Issue 31402 (Invocation arguments)
 async_star_test/04: CompileTimeError # Issue 31402 (Invocation arguments)
 async_star_test/05: CompileTimeError # Issue 31402 (Invocation arguments)
@@ -1499,8 +1497,8 @@
 checked_setter3_test/03: MissingCompileTimeError
 class_cycle_test/02: MissingCompileTimeError
 class_cycle_test/03: MissingCompileTimeError
-class_keyword_test/02: Pass
 class_keyword_test/02: MissingCompileTimeError # Issue 13627
+class_keyword_test/02: Pass
 class_literal_static_test/12: MissingCompileTimeError
 class_literal_static_test/13: MissingCompileTimeError
 class_literal_static_test/17: MissingCompileTimeError
@@ -1642,8 +1640,8 @@
 deferred_constraints_type_annotation_test/type_annotation_generic1: Pass
 deferred_constraints_type_annotation_test/type_annotation_generic2: MissingCompileTimeError
 deferred_constraints_type_annotation_test/type_annotation_generic2: Pass
-deferred_constraints_type_annotation_test/type_annotation_generic3: Pass
 deferred_constraints_type_annotation_test/type_annotation_generic3: MissingCompileTimeError
+deferred_constraints_type_annotation_test/type_annotation_generic3: Pass
 deferred_constraints_type_annotation_test/type_annotation_generic4: MissingCompileTimeError
 deferred_constraints_type_annotation_test/type_annotation_generic4: Pass
 deferred_constraints_type_annotation_test/type_annotation_non_deferred: CompileTimeError
@@ -1974,6 +1972,9 @@
 instanceof4_test/01: RuntimeError
 instanceof4_test/none: Pass
 instanceof4_test/none: RuntimeError
+instantiate_tearoff_after_contravariance_check_test: CompileTimeError
+instantiate_tearoff_of_call_test: CompileTimeError
+instantiate_tearoff_test: CompileTimeError
 int64_literal_test/03: MissingCompileTimeError # http://dartbug.com/31479
 int64_literal_test/30: MissingCompileTimeError # http://dartbug.com/31479
 interface_test/00: MissingCompileTimeError
@@ -2185,8 +2186,8 @@
 mock_writable_final_private_field_test: RuntimeError # Issue 30849
 multiline_strings_test: Pass
 multiline_strings_test: Fail # Issue 23020
-named_constructor_test/01: MissingRuntimeError # Fasta bug: Bad compilation of constructor reference.
 named_constructor_test/01: MissingCompileTimeError
+named_constructor_test/01: MissingRuntimeError # Fasta bug: Bad compilation of constructor reference.
 named_constructor_test/03: MissingCompileTimeError
 named_parameters2_test: MissingCompileTimeError
 named_parameters3_test: MissingCompileTimeError
@@ -2356,8 +2357,8 @@
 regress_28217_test/none: MissingCompileTimeError # Fasta bug: Bad constructor redirection.
 regress_28255_test: SkipByDesign
 regress_28278_test: CompileTimeError # KernelVM bug: Deferred loading kernel issue 28335.
-regress_28341_test: RuntimeError
 regress_28341_test: Pass
+regress_28341_test: RuntimeError
 regress_29025_test: CompileTimeError # Issue 31402 (Variable declaration)
 regress_29405_test: CompileTimeError # Issue 31402 (Invocation arguments)
 regress_29784_test/01: MissingCompileTimeError
@@ -2472,8 +2473,8 @@
 vm/reflect_core_vm_test: SkipByDesign
 vm/regress_27201_test: CompileTimeError # Fasta/KernelVM bug: Deferred loading kernel issue 28335.
 vm/regress_27201_test: Fail
-vm/regress_27671_test: Skip # Unsupported
 vm/regress_27671_test: Crash
+vm/regress_27671_test: Skip # Unsupported
 vm/regress_29145_test: Skip # Issue 29145
 vm/type_cast_vm_test: RuntimeError # Expects line and column numbers
 vm/type_vm_test: RuntimeError, Pass # Expects line and column numbers
diff --git a/tests/language_2/language_2_precompiled.status b/tests/language_2/language_2_precompiled.status
index 730698d..f5f5cd5 100644
--- a/tests/language_2/language_2_precompiled.status
+++ b/tests/language_2/language_2_precompiled.status
@@ -471,6 +471,9 @@
 instanceof2_test: RuntimeError
 instanceof4_test/01: RuntimeError
 instanceof4_test/none: RuntimeError
+instantiate_tearoff_after_contravariance_check_test: RuntimeError
+instantiate_tearoff_of_call_test: RuntimeError
+instantiate_tearoff_test: RuntimeError
 interface_test/00: MissingCompileTimeError
 invalid_cast_test/01: MissingCompileTimeError
 invalid_cast_test/02: MissingCompileTimeError
diff --git a/tests/language_2/language_2_vm.status b/tests/language_2/language_2_vm.status
index 2952f76..360e97e 100644
--- a/tests/language_2/language_2_vm.status
+++ b/tests/language_2/language_2_vm.status
@@ -461,6 +461,9 @@
 initializing_formal_final_test: MissingCompileTimeError
 initializing_formal_type_test: MissingCompileTimeError
 instanceof2_test: RuntimeError
+instantiate_tearoff_after_contravariance_check_test: RuntimeError
+instantiate_tearoff_of_call_test: RuntimeError
+instantiate_tearoff_test: RuntimeError
 interface_test/00: MissingCompileTimeError
 invalid_cast_test/01: MissingCompileTimeError
 invalid_cast_test/02: MissingCompileTimeError
diff --git a/tests/lib_2/lib_2_kernel.status b/tests/lib_2/lib_2_kernel.status
index c963ffb..af19ce3 100644
--- a/tests/lib_2/lib_2_kernel.status
+++ b/tests/lib_2/lib_2_kernel.status
@@ -37,33 +37,14 @@
 async/slow_consumer3_test: CompileTimeError # Issue 31402 (Invocation arguments)
 async/slow_consumer_test: CompileTimeError # Issue 31402 (Invocation arguments)
 async/stream_controller_async_test: CompileTimeError # Issue 31402 (Invocation arguments)
-async/stream_first_where_test: CompileTimeError # Issue 31402 (Invocation arguments)
 async/stream_from_iterable_test: CompileTimeError # Issue 31402 (Invocation arguments)
-async/stream_iterator_test: CompileTimeError # Issue 31402 (Invocation arguments)
 async/stream_join_test: CompileTimeError # Issue 31402 (Invocation arguments)
-async/stream_last_where_test: CompileTimeError # Issue 31402 (Invocation arguments)
-async/stream_periodic2_test: CompileTimeError # Issue 31402 (Invocation arguments)
-async/stream_periodic3_test: CompileTimeError # Issue 31402 (Invocation arguments)
-async/stream_periodic4_test: CompileTimeError # Issue 31402 (Invocation arguments)
-async/stream_periodic5_test: CompileTimeError # Issue 31402 (Invocation arguments)
-async/stream_periodic6_test: CompileTimeError # Issue 31402 (Invocation arguments)
-async/stream_periodic_test: CompileTimeError # Issue 31402 (Invocation arguments)
-async/stream_single_test: CompileTimeError # Issue 31402 (Invocation arguments)
-async/stream_single_to_multi_subscriber_test: CompileTimeError # Issue 31402 (Invocation arguments)
-async/stream_state_nonzero_timer_test: CompileTimeError # Issue 31402 (Invocation arguments)
-async/stream_state_test: CompileTimeError # Issue 31402 (Invocation arguments)
 async/stream_subscription_as_future_test: CompileTimeError # Issue 31402 (Invocation arguments)
-async/stream_subscription_cancel_test: CompileTimeError # Issue 31402 (Invocation arguments)
-async/stream_timeout_test: CompileTimeError # Issue 31402 (Invocation arguments)
-async/stream_transform_test: CompileTimeError # Issue 31402 (Invocation arguments)
-async/stream_transformation_broadcast_test: CompileTimeError # Issue 31402 (Invocation arguments)
-async/timer_cancel1_test: CompileTimeError # Issue 31402 (Invocation arguments)
 async/timer_cancel2_test: CompileTimeError # Issue 31402 (Invocation arguments)
 async/timer_cancel_test: CompileTimeError # Issue 31402 (Invocation arguments)
 async/timer_isActive_test: CompileTimeError # Issue 31402 (Invocation arguments)
 async/timer_not_available_test: RuntimeError
 async/timer_repeat_test: CompileTimeError # Issue 31402 (Invocation arguments)
-async/timer_test: CompileTimeError # Issue 31402 (Invocation arguments)
 async/zone_run_unary_test: CompileTimeError # Issue 31537
 convert/streamed_conversion_json_utf8_decode_test: Pass, Slow # Infrequent timeouts.
 html/*: SkipByDesign # dart:html not supported on VM.
@@ -97,19 +78,18 @@
 isolate/message_test: CompileTimeError # Issue 31402 (Invocation arguments)
 isolate/mint_maker_test: CompileTimeError # Issue 31402 (Invocation arguments)
 isolate/nested_spawn2_test: CompileTimeError # Issue 31402 (Invocation arguments)
-isolate/nested_spawn_test: CompileTimeError # Issue 31402 (Invocation arguments)
+isolate/nested_spawn_test: RuntimeError # Issue 31402 (Invocation arguments)
 isolate/ping_pause_test: Pass, Timeout
 isolate/raw_port_test: CompileTimeError # Issue 31402 (Invocation arguments)
-isolate/request_reply_test: CompileTimeError # Issue 31402 (Invocation arguments)
-isolate/spawn_function_custom_class_test: CompileTimeError # Issue 31402 (Invocation arguments)
-isolate/spawn_function_test: CompileTimeError # Issue 31402 (Invocation arguments)
+isolate/request_reply_test: RuntimeError # Issue 31402 (Invocation arguments)
+isolate/spawn_function_custom_class_test: RuntimeError # Issue 31402 (Invocation arguments)
+isolate/spawn_function_test: RuntimeError # Issue 31402 (Invocation arguments)
 isolate/spawn_uri_exported_main_test: RuntimeError # Issue 31402 (Return and yield statements)
 isolate/spawn_uri_multi_test/none: CompileTimeError # Issue 31402 (Invocation arguments)
 isolate/spawn_uri_nested_vm_test: CompileTimeError # Issue 31402 (Invocation arguments)
 isolate/spawn_uri_test: CompileTimeError # Issue 31402 (Invocation arguments)
 isolate/spawn_uri_vm_test: CompileTimeError # Issue 31402 (Invocation arguments)
-isolate/static_function_test: CompileTimeError # Issue 31402 (Invocation arguments)
-isolate/timer_isolate_test: CompileTimeError # Issue 31402 (Invocation arguments)
+isolate/static_function_test: RuntimeError # Issue 31402 (Invocation arguments)
 isolate/typed_message_test: CompileTimeError # Issue 31402 (Invocation arguments)
 isolate/unresolved_ports_test: CompileTimeError # Issue 31402 (Invocation arguments)
 js/datetime_roundtrip_test: CompileTimeError
@@ -172,8 +152,8 @@
 mirrors/invocation_fuzz_test/string: Crash
 mirrors/invoke_private_test: RuntimeError
 mirrors/invoke_private_wrong_library_test: RuntimeError
-mirrors/invoke_throws_test: RuntimeError
 mirrors/invoke_throws_test: Crash
+mirrors/invoke_throws_test: RuntimeError
 mirrors/lazy_static_test: CompileTimeError # Issue 31402 (Invocation arguments)
 mirrors/library_declarations_test/01: CompileTimeError # Issue 31402 (Invocation arguments)
 mirrors/library_declarations_test/none: CompileTimeError # Issue 31402 (Invocation arguments)
@@ -198,8 +178,6 @@
 mirrors/library_imports_shown_test: CompileTimeError # Issue 31402 (Invocation arguments)
 mirrors/library_imports_shown_test: RuntimeError
 mirrors/library_metadata_test: RuntimeError
-mirrors/library_uri_io_test: CompileTimeError # Issue 31402 (Invocation arguments)
-mirrors/library_uri_package_test: CompileTimeError # Issue 31402 (Invocation arguments)
 mirrors/list_constructor_test/01: Crash
 mirrors/list_constructor_test/01: RuntimeError
 mirrors/list_constructor_test/none: Crash
@@ -295,25 +273,9 @@
 async/slow_consumer_test: RuntimeError
 async/stream_controller_async_test: RuntimeError
 async/stream_distinct_test: RuntimeError
-async/stream_first_where_test: RuntimeError
 async/stream_from_iterable_test: RuntimeError
-async/stream_iterator_test: RuntimeError
 async/stream_join_test: RuntimeError
-async/stream_last_where_test: RuntimeError
-async/stream_periodic2_test: RuntimeError
-async/stream_periodic3_test: RuntimeError
-async/stream_periodic4_test: RuntimeError
-async/stream_periodic5_test: RuntimeError
-async/stream_periodic6_test: RuntimeError
-async/stream_periodic_test: RuntimeError
-async/stream_single_test: RuntimeError
-async/stream_single_to_multi_subscriber_test: RuntimeError
-async/stream_state_test: RuntimeError
 async/stream_subscription_as_future_test: RuntimeError
-async/stream_subscription_cancel_test: RuntimeError
-async/stream_timeout_test: RuntimeError
-async/stream_transform_test: RuntimeError
-async/stream_transformation_broadcast_test: RuntimeError
 async/timer_cancel2_test: RuntimeError
 async/timer_cancel_test: RuntimeError
 async/timer_isActive_test: RuntimeError
@@ -360,7 +322,6 @@
 isolate/spawn_uri_vm_test: RuntimeError
 isolate/stacktrace_message_test: RuntimeError
 isolate/static_function_test: Timeout
-isolate/timer_isolate_test: RuntimeError
 isolate/typed_message_test: RuntimeError
 isolate/unresolved_ports_test: RuntimeError
 mirrors/class_mirror_type_variables_test: RuntimeError