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 // Ensure that dart2js's receiver specialization optimization works |
| 6 // with captured variables. |
| 7 |
| 8 import "package:expect/expect.dart"; |
| 9 |
| 10 var list = [new Object(), 31]; |
| 11 |
| 12 main() { |
| 13 Expect.throws(() => foo()() + 42, (e) => e is NoSuchMethodError); |
| 14 } |
| 15 |
| 16 foo() { |
| 17 var a = list[0]; |
| 18 var closure = (() => a + 42); |
| 19 if (list[1] == 0) { |
| 20 a.toInt(); |
| 21 return closure; |
| 22 } |
| 23 return closure; |
| 24 } |
OLD | NEW |