OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 class A { |
| 6 num x; |
| 7 A() : this.x = 0; |
| 8 |
| 9 void bar(){ |
| 10 // dart2js hoisted the this.x out of the loop, and missed that setX would |
| 11 // change the value. |
| 12 for (int i = 1; i < 3; i++) { |
| 13 setX(499); |
| 14 foo(x); |
| 15 break; |
| 16 } |
| 17 } |
| 18 setX(x) => this.x = x; |
| 19 } |
| 20 |
| 21 var saved; |
| 22 foo(x) => saved = x; |
| 23 |
| 24 main() { |
| 25 A a = new A(); |
| 26 for (int i = 0; i < 1; i++) { |
| 27 a.bar(); |
| 28 } |
| 29 Expect.equals(499, saved); |
| 30 } |
OLD | NEW |