| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2017, 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 // Regression test for http://dartbug.com/28919. |
| 6 // |
| 7 // This would crash at runtime because the type of closure parameter 'x' was |
| 8 // empty, leading to bad codegen. The empty type was due to a tracing bug that |
| 9 // failed to escape the closure when stored into the list which was not traced |
| 10 // as a container. |
| 11 |
| 12 import 'package:expect/expect.dart'; |
| 13 |
| 14 int foo([List _methods = const []]) { |
| 15 final methods = new List.from(_methods); |
| 16 for (int i = 0; i < 3; i++) { |
| 17 methods.add((int x) => x + i); |
| 18 } |
| 19 return methods[0](499); |
| 20 } |
| 21 |
| 22 main() { |
| 23 Expect.equals(499, foo()); |
| 24 } |
| OLD | NEW |