mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
Flow analysis: Test that functionExpression_begin() preserves promotions of initialized vars.
While working on some other changes to flow analysis, I discovered that this particular behaviour wasn't unit tested. Change-Id: Ia9b27672c62177ffed80d4143f33c5b764ac7bbe Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313242 Commit-Queue: Paul Berry <paulberry@google.com> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
760c719b97
commit
53ead360bb
|
@ -969,6 +969,31 @@ main() {
|
|||
]);
|
||||
});
|
||||
|
||||
test('functionExpression_begin() preserves promotions of initialized vars',
|
||||
() {
|
||||
var x = Var('x');
|
||||
var y = Var('y');
|
||||
h.run([
|
||||
declare(x, type: 'int?', initializer: expr('int?')),
|
||||
declare(y, type: 'int?', initializer: expr('int?'), isLate: true),
|
||||
x.expr.as_('int'),
|
||||
y.expr.as_('int'),
|
||||
checkPromoted(x, 'int'),
|
||||
checkPromoted(y, 'int'),
|
||||
localFunction([
|
||||
// x and y remain promoted within the local function, because the
|
||||
// assignment that happens implicitly as part of the initialization
|
||||
// definitely happens before anything else, and hence the promotions
|
||||
// are still valid whenever the local function executes.
|
||||
checkPromoted(x, 'int'),
|
||||
checkPromoted(y, 'int'),
|
||||
]),
|
||||
// x and y remain promoted after the local function too.
|
||||
checkPromoted(x, 'int'),
|
||||
checkPromoted(y, 'int'),
|
||||
]);
|
||||
});
|
||||
|
||||
test('functionExpression_begin() handles not-yet-seen variables', () {
|
||||
var x = Var('x');
|
||||
h.run([
|
||||
|
|
Loading…
Reference in a new issue