Skip to content

Commit

Permalink
[nnbd_migration] Add api test for how we don't plan to handle postdom…
Browse files Browse the repository at this point in the history
…inators of cfg edits

Change-Id: I8588297a42584a474508a61c4fb83268da7ab615
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112757
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
  • Loading branch information
MichaelRFairhurst authored and commit-bot@chromium.org committed Aug 13, 2019
1 parent 78efb23 commit 9ed7471
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions pkg/nnbd_migration/test/api_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1806,6 +1806,42 @@ int f(int x, int Function(int i) g) {
await _checkSingleFileChanges(content, expected);
}

test_postdominating_usage_after_cfg_altered() async {
// By altering the control-flow graph, we can create new postdominators,
// which are not recognized as such. This is not a problem as we only do
// hard edges on a best-effort basis, and this case would be a lot of
// additional complexity.
var content = '''
int f(int a, int b, int c) {
if (a != null) {
b.toDouble();
} else {
return null;
}
c.toDouble;
}
void main() {
f(1, null, null);
}
''';
var expected = '''
int f(int a, int? b, int? c) {
/* if (a != null) {
*/ b!.toDouble(); /*
} else {
return null;
} */
c!.toDouble;
}
void main() {
f(1, null, null);
}
''';
await _checkSingleFileChanges(content, expected);
}

test_prefix_minus() async {
var content = '''
class C {
Expand Down

0 comments on commit 9ed7471

Please sign in to comment.