[vm/kernel] Fix partial instantiation implementation in StreamingConstantEvaluator.

# Summary

As part of commit 772c9bb5f, we changed the representation of partially
instantiated closures to facilitate partial instantiation of local functions.
The compile-time constant evaluator was not updated -- this revision implements
that update.

Fixes task 33211.

# Test Plan

Updated `partial_tearoff_instantiation_test.dart` to test the case which caused
incorrect behavior in task 33211.

Change-Id: I7bbd4fb83a5aea86ffc85c1d9952f1202f098d6b
Reviewed-on: https://dart-review.googlesource.com/56346
Reviewed-by: RĂ©gis Crelier <regis@google.com>
Commit-Queue: Samir Jindel <sjindel@google.com>
diff --git a/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc b/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc
index ddea9fe..012a3c3 100644
--- a/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc
+++ b/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc
@@ -4069,26 +4069,16 @@
   // read type arguments.
   intptr_t num_type_args = builder_->ReadListLength();
   const TypeArguments* type_args = &T.BuildTypeArguments(num_type_args);
-  // Even if all dynamic types are passed in, we need to put a vector in here to
-  // distinguish this partially applied tearoff from a normal tearoff. This is
-  // necessary because the tearoff wrapper (BuildGraphOfImplicitClosureFunction)
-  // needs to throw NSM if type arguments are passed to a partially applied
-  // tearoff.
-  if (type_args->IsNull()) {
-    type_args =
-        &TypeArguments::ZoneHandle(Z, TypeArguments::New(num_type_args));
-    for (intptr_t i = 0; i < num_type_args; ++i) {
-      type_args->SetTypeAt(i, Type::ZoneHandle(Z, Type::DynamicType()));
-    }
-  }
 
   // Create new closure with the type arguments inserted, and other things
   // copied over.
   Closure& new_closure = Closure::Handle(
-      Z, Closure::New(TypeArguments::Handle(
-                          Z, old_closure.instantiator_type_arguments()),
-                      *type_args, Function::Handle(Z, old_closure.function()),
-                      Context::Handle(Z, old_closure.context()), Heap::kOld));
+      Z,
+      Closure::New(
+          TypeArguments::Handle(Z, old_closure.instantiator_type_arguments()),
+          TypeArguments::Handle(old_closure.function_type_arguments()),
+          *type_args, Function::Handle(Z, old_closure.function()),
+          Context::Handle(Z, old_closure.context()), Heap::kOld));
   result_ = H.Canonicalize(new_closure);
 }
 
diff --git a/tests/language_2/partial_tearoff_instantiation_test.dart b/tests/language_2/partial_tearoff_instantiation_test.dart
index 72bd744..b534a96 100644
--- a/tests/language_2/partial_tearoff_instantiation_test.dart
+++ b/tests/language_2/partial_tearoff_instantiation_test.dart
@@ -112,5 +112,10 @@
 
     // Not OK with a type argument.
     y.f<String>("hello6"); //# 08: compile-time error
+
+    // Correct runtime type of x.f.
+    void instantiatedFType(dynamic _) {}
+    Expect.equals(x.f.runtimeType.toString(),
+        instantiatedFType.runtimeType.toString()); // #09: ok
   }
 }