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

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

Issue 2981603002: Convert closures in all initializers, and share the context between them. (Closed)
Patch Set: Review comments. Created 3 years, 5 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/info.dart
diff --git a/pkg/kernel/lib/transformations/closure/info.dart b/pkg/kernel/lib/transformations/closure/info.dart
index 408d37c61a7563336ae19f8eae4656ab0d9460d7..8d6645b8edb64e5b91e3a169d3871022972c447d 100644
--- a/pkg/kernel/lib/transformations/closure/info.dart
+++ b/pkg/kernel/lib/transformations/closure/info.dart
@@ -21,7 +21,8 @@ import '../../ast.dart'
TypeParameterType,
VariableDeclaration,
VariableGet,
- VariableSet;
+ VariableSet,
+ visitList;
import '../../visitor.dart' show RecursiveVisitor;
@@ -119,9 +120,19 @@ class ClosureInfo extends RecursiveVisitor {
/// the constructor (which is not `null`). It leads to `x` being treated as
/// captured, because it's seen as used outside of the function where it is
/// declared. In turn, it leads to unnecessary context creation and usage.
+ ///
+ /// We also need to visit the parameters to the function node before the
+ /// initializer list. Since the default [visitChildren] method of
+ /// [Constructor] will visit initializers first, we manually visit the
+ /// parameters here.
+ ///
+ /// TODO(sjindel): Don't visit the parameters twice.
+ ///
beginMember(node, node.function);
saveCurrentFunction(() {
currentFunction = currentMemberFunction;
+ visitList(node.function.positionalParameters, this);
+ visitList(node.function.namedParameters, this);
super.visitConstructor(node);
});
endMember();
« no previous file with comments | « pkg/kernel/lib/transformations/closure/converter.dart ('k') | pkg/kernel/lib/transformations/closure/rewriter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698