Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(434)

Unified Diff: runtime/vm/kernel_to_il.cc

Issue 2912393004: Kernel/VM: Set the instantiator type arguments on closures (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/language/language_kernel.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/kernel_to_il.cc
diff --git a/runtime/vm/kernel_to_il.cc b/runtime/vm/kernel_to_il.cc
index f28bad745a34d0848626b423151e964d28f9a32b..b7c0c185e31d50d50cb6363824ef173e4907eb39 100644
--- a/runtime/vm/kernel_to_il.cc
+++ b/runtime/vm/kernel_to_il.cc
@@ -3798,6 +3798,18 @@ Fragment FlowGraphBuilder::BuildImplicitClosureCreation(
fragment += AllocateObject(closure_class, target);
LocalVariable* closure = MakeTemporary();
+ // The function signature can have uninstantiated class type parameters.
+ //
+ // TODO(regis): Also handle the case of a function signature that has
+ // uninstantiated function type parameters.
+ if (!target.HasInstantiatedSignature(kCurrentClass)) {
+ fragment += LoadLocal(closure);
+ fragment += LoadInstantiatorTypeArguments();
+ fragment +=
+ StoreInstanceField(TokenPosition::kNoSource,
+ Closure::instantiator_type_arguments_offset());
+ }
+
// Allocate a context that closes over `this`.
fragment += AllocateContext(1);
LocalVariable* context = MakeTemporary();
@@ -6697,7 +6709,17 @@ Fragment FlowGraphBuilder::TranslateFunctionNode(FunctionNode* node,
Fragment instructions = AllocateObject(closure_class, function);
LocalVariable* closure = MakeTemporary();
- // TODO(27590): Generic closures need type arguments.
+ // The function signature can have uninstantiated class type parameters.
+ //
+ // TODO(regis): Also handle the case of a function signature that has
+ // uninstantiated function type parameters.
+ if (!function.HasInstantiatedSignature(kCurrentClass)) {
+ instructions += LoadLocal(closure);
+ instructions += LoadInstantiatorTypeArguments();
+ instructions +=
+ StoreInstanceField(TokenPosition::kNoSource,
+ Closure::instantiator_type_arguments_offset());
+ }
// Store the function and the context in the closure.
instructions += LoadLocal(closure);
« no previous file with comments | « no previous file | tests/language/language_kernel.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698