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

Unified Diff: pkg/kernel/lib/transformations/closure/converter.dart

Issue 2998803002: [kernel] Support for top-level generic functions. (Closed)
Patch Set: Review comments. Created 3 years, 4 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
Index: pkg/kernel/lib/transformations/closure/converter.dart
diff --git a/pkg/kernel/lib/transformations/closure/converter.dart b/pkg/kernel/lib/transformations/closure/converter.dart
index 42562b2992eedb5092a7e89d5a3f018ca2704a0b..ce77ee065c88d308143c7abf1ddc069ab5bf3804 100644
--- a/pkg/kernel/lib/transformations/closure/converter.dart
+++ b/pkg/kernel/lib/transformations/closure/converter.dart
@@ -50,6 +50,7 @@ import '../../ast.dart'
VariableDeclaration,
VariableGet,
VariableSet,
+ VectorCreation,
VectorType,
transformList;
@@ -445,6 +446,13 @@ class ClosureConverter extends Transformer {
typeParameters: closureTypeParams,
requiredParameterCount: function.requiredParameterCount - 1);
+ // If we capture type parameters but not regular variables, we still need to
+ // make a context.
+ if (capturedTypeVariables[function] != null &&
+ accessContext is NullLiteral) {
+ accessContext = new VectorCreation(1);
+ }
+
return new ClosureCreation(
closedTopLevelFunction, accessContext, closureType, fnTypeArgs);
}
@@ -740,9 +748,7 @@ class ClosureConverter extends Transformer {
/// Creates copies of the type variables in [original] and returns a
/// substitution that can be passed to [substitute] to substitute all uses of
- /// [original] with their copies. Additionally returns a list of new type
- /// parameters to prefix to the enclosing function's type parameters and the
- /// arguments to be passed for those parameters.
+ /// [original] with their copies.
///
Map<TypeParameter, DartType> copyTypeVariables(
Iterable<TypeParameter> original) {
« no previous file with comments | « pkg/kernel/lib/transformations/closure/context.dart ('k') | pkg/kernel/lib/transformations/closure/rewriter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698