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