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

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

Issue 2891053003: Add support for converted closures with explicit contexts to VM (Closed)
Patch Set: Temporarily disable Run step in closures test suite 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 08d6a5a4fc33a22339aa09d64b72fbe5dc93c8f2..68b82c1dc5e51e0c5fd4393e813aafc780f3a49d 100644
--- a/pkg/kernel/lib/transformations/closure/info.dart
+++ b/pkg/kernel/lib/transformations/closure/info.dart
@@ -93,19 +93,21 @@ class ClosureInfo extends RecursiveVisitor {
/// 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.
- ///
+ /// Another consideration is the order of visiting children of the
+ /// constructor: [node.function] should be visited before
+ /// [node.initializers], because [node.function] contains declarations of
+ /// the parameters that may be used in the initializers. If the nodes are
+ /// visited in another order, the encountered parameters in initializers
+ /// are treated as captured, because they are not yet associated with the
+ /// function.
beginMember(node, node.function);
saveCurrentFunction(() {
currentFunction = currentMemberFunction;
- visitList(node.function.positionalParameters, this);
- visitList(node.function.namedParameters, this);
- super.visitConstructor(node);
+
+ visitList(node.annotations, this);
+ node.name?.accept(this);
+ node.function?.accept(this);
+ visitList(node.initializers, this);
});
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