| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2014, 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 import "package:expect/expect.dart"; |
| 6 |
| 7 // Regression test for issue 17483. |
| 8 |
| 9 class A { |
| 10 var x, y; |
| 11 A(x, this.y) { |
| 12 this.x = x; |
| 13 } |
| 14 toString() => "a"; |
| 15 } |
| 16 |
| 17 foo(trace) => trace.add("foo"); |
| 18 bar(trace) => trace.add("bar"); |
| 19 |
| 20 main() { |
| 21 var trace = []; |
| 22 // Dart2js must keep the order of t1 and t2. |
| 23 var t1 = foo(trace); |
| 24 var t2 = bar(trace); |
| 25 // Dart2js inlines the constructor, yielding something like: |
| 26 // t3 = jsNew A(null, t2); // Note that jsNew is pure. |
| 27 // t3.x = t1; |
| 28 // t3 is used twice and cannot be generated at use site. |
| 29 // Dart2js must not allow t1 to cross the t3-line. |
| 30 var a = new A(t1, t2); |
| 31 // Use a. It is already implicitly used by the this.x = x line in its |
| 32 // constructor. With the following use we use it twice and make sure that |
| 33 // the allocation can not be generated at use-site. |
| 34 trace.add(a.toString()); |
| 35 Expect.listEquals(["foo", "bar", "a"], trace); |
| 36 } |
| OLD | NEW |