Index: pkg/kernel/lib/transformations/closure/rewriter.dart |
diff --git a/pkg/kernel/lib/transformations/closure/rewriter.dart b/pkg/kernel/lib/transformations/closure/rewriter.dart |
index 255398cb061bccc3658478b2c2066477a5a732ae..41b1a408eff10157c6065c6bc082d2d296c3946d 100644 |
--- a/pkg/kernel/lib/transformations/closure/rewriter.dart |
+++ b/pkg/kernel/lib/transformations/closure/rewriter.dart |
@@ -100,9 +100,10 @@ abstract class InitializerRewriter extends AstRewriter { |
@override |
void insertContextDeclaration(Expression accessParent) { |
_createDeclaration(); |
+ var oldParent = initializingExpression.parent; |
Let binding = new Let(contextDeclaration, initializingExpression); |
+ binding.parent = oldParent; |
setInitializerExpression(binding); |
- initializingExpression.parent = binding; |
} |
@override |
@@ -124,23 +125,19 @@ class FieldInitializerRewriter extends InitializerRewriter { |
} |
void setInitializerExpression(Expression expression) { |
- assert(initializingExpression.parent is FieldInitializer); |
- FieldInitializer parent = initializingExpression.parent; |
- parent.value = expression; |
- expression.parent = parent; |
+ expression.parent.value = expression; |
} |
} |
class LocalInitializerRewriter extends InitializerRewriter { |
LocalInitializerRewriter(Expression initializingExpression) |
: super(initializingExpression) { |
- assert(initializingExpression.parent is LocalInitializer); |
+ // The initializer is up two levels because the variable declaration node is |
+ // in between. |
+ assert(initializingExpression.parent.parent is LocalInitializer); |
} |
void setInitializerExpression(Expression expression) { |
- assert(initializingExpression.parent is LocalInitializer); |
- LocalInitializer parent = initializingExpression.parent; |
- parent.variable.initializer = expression; |
- expression.parent = parent; |
+ expression.parent.initializer = expression; |
} |
} |