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

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

Issue 2998803002: [kernel] Support for top-level generic functions. (Closed)
Patch Set: Fix test. 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..64f6324a75b862c08b562c06802d054fe6f47255 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,11 @@ 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)
jensj 2017/08/11 06:24:54 https://www.dartlang.org/guides/language/effective
sjindel 2017/08/11 09:21:06 Done.
+ accessContext = new VectorCreation(1);
+
return new ClosureCreation(
closedTopLevelFunction, accessContext, closureType, fnTypeArgs);
}
@@ -740,9 +746,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) {

Powered by Google App Engine
This is Rietveld 408576698