| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2013, 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 // dart2js regression test for issue 8781. |
| 6 |
| 7 class N { |
| 8 var outgoing; |
| 9 var incoming; |
| 10 N(this.outgoing, this.incoming); |
| 11 } |
| 12 |
| 13 class A { |
| 14 int offset = 0; |
| 15 var list; |
| 16 var node; |
| 17 |
| 18 A(node) : node = node, list = node.outgoing; |
| 19 |
| 20 next() { |
| 21 // dart2js used to update [offset] twice: once in the optimized |
| 22 // version, which would bailout to the non-optimized version |
| 23 // because [list] is not an Array, and once in the non-optimized |
| 24 // version. |
| 25 var edge = list[offset++]; |
| 26 if (list == node.outgoing) { |
| 27 list = node.incoming; |
| 28 offset = 0; |
| 29 } else |
| 30 list = null; |
| 31 return edge; |
| 32 } |
| 33 } |
| 34 |
| 35 class L { |
| 36 final list; |
| 37 L(this.list); |
| 38 // Use noSuchMethod to defeat type inferencing. |
| 39 noSuchMethod(mirror) => mirror.invokeOn(list); |
| 40 } |
| 41 |
| 42 main () { |
| 43 var o = new A(new N(new L([1]), new L([2]))); |
| 44 |
| 45 for (var i = 1; i <= 2; i++) |
| 46 Expect.equals(i, o.next()); |
| 47 |
| 48 Expect.equals(null, o.list); |
| 49 } |
| OLD | NEW |