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

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: Fix unnecessary context bug. 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..0d9c1e5a8cfef3eb4a966cc6ea977598a5a4e9cf 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,17 @@ 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
Dmitry Stefantsov 2017/07/13 07:19:53 I suppose you can also use square-bracket notation
sjindel 2017/07/13 11:34:04 Done.
+ /// [Constructor] will visit initializers first, we manually visit the
+ /// parameters here. It doesn't matter that they get double-visited.
+ ///
beginMember(node, node.function);
saveCurrentFunction(() {
currentFunction = currentMemberFunction;
+ visitList(node.function.positionalParameters, this);
+ visitList(node.function.namedParameters, this);
super.visitConstructor(node);
});
endMember();

Powered by Google App Engine
This is Rietveld 408576698