Skip to content

Commit 9ed7471

Browse files
[nnbd_migration] Add api test for how we don't plan to handle postdominators of cfg edits
Change-Id: I8588297a42584a474508a61c4fb83268da7ab615 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112757 Commit-Queue: Mike Fairhurst <[email protected]> Reviewed-by: Paul Berry <[email protected]>
1 parent 78efb23 commit 9ed7471

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

pkg/nnbd_migration/test/api_test.dart

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1806,6 +1806,42 @@ int f(int x, int Function(int i) g) {
18061806
await _checkSingleFileChanges(content, expected);
18071807
}
18081808

1809+
test_postdominating_usage_after_cfg_altered() async {
1810+
// By altering the control-flow graph, we can create new postdominators,
1811+
// which are not recognized as such. This is not a problem as we only do
1812+
// hard edges on a best-effort basis, and this case would be a lot of
1813+
// additional complexity.
1814+
var content = '''
1815+
int f(int a, int b, int c) {
1816+
if (a != null) {
1817+
b.toDouble();
1818+
} else {
1819+
return null;
1820+
}
1821+
c.toDouble;
1822+
}
1823+
1824+
void main() {
1825+
f(1, null, null);
1826+
}
1827+
''';
1828+
var expected = '''
1829+
int f(int a, int? b, int? c) {
1830+
/* if (a != null) {
1831+
*/ b!.toDouble(); /*
1832+
} else {
1833+
return null;
1834+
} */
1835+
c!.toDouble;
1836+
}
1837+
1838+
void main() {
1839+
f(1, null, null);
1840+
}
1841+
''';
1842+
await _checkSingleFileChanges(content, expected);
1843+
}
1844+
18091845
test_prefix_minus() async {
18101846
var content = '''
18111847
class C {

0 commit comments

Comments
 (0)