mirror of
https://github.com/dart-lang/sdk
synced 2024-11-05 18:22:09 +00:00
Fix exception thrown in ConditionalModification
Change-Id: I6e60bd74bc55cafca86a64a721455e0ed465a357 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106101 Commit-Queue: Brian Wilkerson <brianwilkerson@google.com> Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Reviewed-by: Paul Berry <paulberry@google.com>
This commit is contained in:
parent
a02d6de474
commit
dcc85a6594
2 changed files with 18 additions and 2 deletions
|
@ -33,7 +33,7 @@ class ConditionalModification extends PotentialModification {
|
||||||
discard,
|
discard,
|
||||||
_KeepNode(node.condition),
|
_KeepNode(node.condition),
|
||||||
_KeepNode(node.thenStatement),
|
_KeepNode(node.thenStatement),
|
||||||
_KeepNode(node.elseStatement));
|
node.elseStatement == null ? null : _KeepNode(node.elseStatement));
|
||||||
} else {
|
} else {
|
||||||
throw new UnimplementedError('TODO(paulberry)');
|
throw new UnimplementedError('TODO(paulberry)');
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ class ConditionalModification extends PotentialModification {
|
||||||
if (discard.keepTrue) {
|
if (discard.keepTrue) {
|
||||||
keepNodes.add(thenStatement); // TODO(paulberry): test
|
keepNodes.add(thenStatement); // TODO(paulberry): test
|
||||||
}
|
}
|
||||||
if (discard.keepFalse) {
|
if (discard.keepFalse && elseStatement != null) {
|
||||||
keepNodes.add(elseStatement); // TODO(paulberry): test
|
keepNodes.add(elseStatement); // TODO(paulberry): test
|
||||||
}
|
}
|
||||||
// TODO(paulberry): test thoroughly
|
// TODO(paulberry): test thoroughly
|
||||||
|
|
|
@ -694,6 +694,22 @@ int get g => 0;
|
||||||
await _checkSingleFileChanges(content, expected);
|
await _checkSingleFileChanges(content, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test_ifStatement_nullCheck_noElse() async {
|
||||||
|
var content = '''
|
||||||
|
int f(int x) {
|
||||||
|
if (x == null) return 0;
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
''';
|
||||||
|
var expected = '''
|
||||||
|
int f(int x) {
|
||||||
|
if (x == null) return 0;
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
''';
|
||||||
|
await _checkSingleFileChanges(content, expected);
|
||||||
|
}
|
||||||
|
|
||||||
test_instanceCreation_noTypeArguments_noParameters() async {
|
test_instanceCreation_noTypeArguments_noParameters() async {
|
||||||
var content = '''
|
var content = '''
|
||||||
void main() {
|
void main() {
|
||||||
|
|
Loading…
Reference in a new issue