Files
sdk/pkg/front_end/testcases/inference/bug31133.dart
T
Paul Berry 485aa072d9 Fix type inference of expressions in for loop initializers.
BodyBuilder converts an expression in a for loop initializer to the
initialization of a dummy variable.  It needed to create this dummy
variable using ShadowVariableDeclaration to ensure that type inference
would be applied to the dummy variable.

Fixes #31133

Change-Id: Ibe5ed95f20429af633cbe8d49b06aabaa9df41fd
Reviewed-on: https://dart-review.googlesource.com/15001
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2017-10-18 22:44:23 +00:00

17 lines
506 B
Dart

// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
/*@testedFeatures=inference*/
library test;
void test() {
var /*@type=int*/ i = 0;
for (i++; i /*@target=num::<*/ < 10; i++) {}
for (++i; i /*@target=num::<*/ < 10; i++) {}
for (i--; i /*@target=num::>=*/ >= 0; i--) {}
for (--i; i /*@target=num::>=*/ >= 0; i--) {}
}
main() {}