| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 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 | 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"; | |
| 6 | |
| 7 // Regression test for dart2js that used to crash on this program. | 5 // Regression test for dart2js that used to crash on this program. |
| 8 | 6 |
| 9 class A { | 7 class A { |
| 10 var b; | 8 var b; |
| 11 | 9 |
| 12 // The parameter check here used to confuse the SSA builder when it | 10 // The parameter check here used to confuse the SSA builder when it |
| 13 // created the call to the constructor body. | 11 // created the call to the constructor body. |
| 14 A([Map a]) : b = ?a { | 12 A([Map a]) : b = ?a { |
| 15 Expect.isTrue(b); | 13 Expect.isTrue(b); |
| 16 } | 14 } |
| 17 | 15 |
| 18 // The closure in the constructor body used to confuse the SSA builder | 16 // The closure in the constructor body used to confuse the SSA builder |
| 19 // when it created the call to the constructor body. | 17 // when it created the call to the constructor body. |
| 20 A.withClosure(Map a) { | 18 A.withClosure(Map a) { |
| 21 var c; | 19 var c; |
| 22 var f = () { return c = 42; }; | 20 var f = () { return c = 42; }; |
| 23 b = f(); | 21 b = f(); |
| 24 Expect.equals(42, b); | 22 Expect.equals(42, b); |
| 25 Expect.equals(42, c); | 23 Expect.equals(42, c); |
| 26 } | 24 } |
| 27 } | 25 } |
| 28 | 26 |
| 29 main() { | 27 main() { |
| 30 new A(null); | 28 new A(null); |
| 31 new A({}); | 29 new A({}); |
| 32 new A.withClosure(null); | 30 new A.withClosure(null); |
| 33 new A.withClosure({}); | 31 new A.withClosure({}); |
| 34 } | 32 } |
| OLD | NEW |