Update definite assignment for the code-as-ui changes

Change-Id: Id425fd6eb76402118738da13275224ae2d1905aa
Reviewed-on: https://dart-review.googlesource.com/c/91168
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
Brian Wilkerson 2019-01-25 22:28:05 +00:00 committed by commit-bot@chromium.org
parent fe285e3e60
commit 2f3ebf70f6
2 changed files with 43 additions and 1 deletions

View file

@ -1,4 +1,4 @@
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
@ -546,6 +546,12 @@ class DefiniteAssignmentTracker {
_statementToStackIndex[statement] = _stack.length;
}
void beginForStatement2(ForStatement2 statement) {
// Not strongly necessary, because we discard everything anyway.
// Just for consistency, so that `break` is handled without `null`.
_statementToStackIndex[statement] = _stack.length;
}
void beginForStatementBody() {
_stack.add(_current); // break set
_stack.add(_ElementSet.empty); // continue set

View file

@ -1356,6 +1356,42 @@ class _AstVisitor extends RecursiveAstVisitor<void> {
tracker.endForStatement();
}
@override
void visitForStatement2(ForStatement2 node) {
var parts = node.forLoopParts;
VariableDeclarationList variables;
Expression initialization;
Expression condition;
Expression iterable;
NodeList<Expression> updaters;
if (parts is ForPartsWithDeclarations) {
variables = parts.variables;
condition = parts.condition;
updaters = parts.updaters;
} else if (parts is ForPartsWithExpression) {
initialization = parts.initialization;
condition = parts.condition;
updaters = parts.updaters;
} else if (parts is ForEachParts) {
iterable = parts.iterable;
}
tracker.beginForStatement2(node);
variables?.accept(this);
initialization?.accept(this);
condition?.accept(this);
iterable?.accept(this);
tracker.beginForStatementBody();
node.body?.accept(this);
tracker.beginForStatementUpdaters();
updaters?.accept(this);
tracker.endForStatement();
}
@override
void visitFunctionDeclaration(FunctionDeclaration node) {
super.visitFunctionDeclaration(node);