Skip to content

Commit 6893885

Browse files
[nnbd_migration] Handle do while
Change-Id: I97071b6b59c9450fddcf7f3ea2da19c99bff4682 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112407 Reviewed-by: Brian Wilkerson <[email protected]> Reviewed-by: Paul Berry <[email protected]> Commit-Queue: Mike Fairhurst <[email protected]>
1 parent 1f4d251 commit 6893885

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

pkg/nnbd_migration/lib/src/edge_builder.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,13 @@ class EdgeBuilder extends GeneralizingAstVisitor<DecoratedType>
419419
return null;
420420
}
421421

422+
@override
423+
DecoratedType visitDoStatement(DoStatement node) {
424+
node.body.accept(this);
425+
_handleAssignment(node.condition, _notNullType);
426+
return null;
427+
}
428+
422429
@override
423430
DecoratedType visitDoubleLiteral(DoubleLiteral node) {
424431
return DecoratedType(node.staticType, _graph.never);

pkg/nnbd_migration/test/edge_builder_test.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,6 +1335,17 @@ class C {
13351335
hard: true);
13361336
}
13371337

1338+
test_do_while_condition() async {
1339+
await analyze('''
1340+
void f(bool b) {
1341+
do {} while (b);
1342+
}
1343+
''');
1344+
1345+
assertNullCheck(checkExpression('b);'),
1346+
assertEdge(decoratedTypeAnnotation('bool b').node, never, hard: true));
1347+
}
1348+
13381349
test_doubleLiteral() async {
13391350
await analyze('''
13401351
double f() {

0 commit comments

Comments
 (0)