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 2d9c2ca3c90f6f38ea3b78201741b63a3eaa7c94..83f981423f51b612bd1d2be229324d0a791a9636 100644 |
--- a/pkg/kernel/lib/transformations/closure/info.dart |
+++ b/pkg/kernel/lib/transformations/closure/info.dart |
@@ -9,13 +9,17 @@ import '../../ast.dart' |
Class, |
Constructor, |
Field, |
+ FieldInitializer, |
FunctionDeclaration, |
FunctionNode, |
+ LocalInitializer, |
Member, |
Name, |
Procedure, |
ProcedureKind, |
PropertyGet, |
+ RedirectingInitializer, |
+ SuperInitializer, |
ThisExpression, |
TypeParameter, |
TypeParameterType, |
@@ -209,4 +213,38 @@ class ClosureInfo extends RecursiveVisitor { |
invokedGetters.add(node.name); |
super.visitPropertyGet(node); |
} |
+ |
+ visitFieldInitializer(FieldInitializer node) { |
karlklose
2017/06/16 07:54:43
Consider adding a helper and move the comment ther
Dmitry Stefantsov
2017/06/16 08:30:00
Thanks! I agree, an example could help with under
|
+ // Set [currentFunction] to [currentMemberFunction] during visiting the |
+ // initializer. Effectively it means that [currentFunction] is set to |
+ // [function] field of the constructor, and constructor parameters |
+ // encountered in the initializer won't be treated as captured. |
+ // Same trick is used in [visitSuperInitializer], |
+ // [visitRedirectingInitializer], and [visitLocalInitializer]. |
+ var saved = currentFunction; |
+ currentFunction = currentMemberFunction; |
+ super.visitFieldInitializer(node); |
+ currentFunction = saved; |
+ } |
+ |
+ visitSuperInitializer(SuperInitializer node) { |
+ var saved = currentFunction; |
+ currentFunction = currentMemberFunction; |
+ super.visitSuperInitializer(node); |
+ currentFunction = saved; |
+ } |
+ |
+ visitRedirectingInitializer(RedirectingInitializer node) { |
+ var saved = currentFunction; |
+ currentFunction = currentMemberFunction; |
+ super.visitRedirectingInitializer(node); |
+ currentFunction = saved; |
+ } |
+ |
+ visitLocalInitializer(LocalInitializer node) { |
+ var saved = currentFunction; |
+ currentFunction = currentMemberFunction; |
+ super.visitLocalInitializer(node); |
+ currentFunction = saved; |
+ } |
} |