Skip to content

Commit 780af0f

Browse files
stereotype441commit-bot@chromium.org
authored and
commit-bot@chromium.org
committed
Flow analysis: promote to "types of interest" on assignment.
This allows so-called "ensure guarded" promotions, e.g. - `if (x is! int) x = 0;` - `if (x == null) x = 0;` - `x ??= 0;` The latter two are particularly important to prepare for NNBD. Change-Id: Ib53ca916e6d485945326b19e86f8cfb5b3ee2160 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123280 Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Paul Berry <paulberry@google.com>
1 parent d213d3c commit 780af0f

File tree

11 files changed

+831
-302
lines changed

11 files changed

+831
-302
lines changed

pkg/analyzer/lib/src/dart/resolver/flow_analysis_visitor.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class FlowAnalysisHelper {
7777
if (flow == null) return null;
7878

7979
if (node.operator.type == TokenType.QUESTION_QUESTION_EQ) {
80-
flow.ifNullExpression_rightBegin();
80+
flow.ifNullExpression_rightBegin(node.leftHandSide);
8181
}
8282

8383
var left = node.leftHandSide;

pkg/analyzer/lib/src/generated/resolver.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -3130,7 +3130,7 @@ class ResolverVisitor extends ScopedVisitor {
31303130
}
31313131

31323132
if (operator == TokenType.QUESTION_QUESTION) {
3133-
flow?.ifNullExpression_rightBegin();
3133+
flow?.ifNullExpression_rightBegin(node.leftOperand);
31343134
right.accept(this);
31353135
flow?.ifNullExpression_end();
31363136
} else {

pkg/front_end/lib/src/fasta/flow_analysis/flow_analysis.dart

+382-190
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)