OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 |
5 class A { | 7 class A { |
6 operator -() => this; | 8 operator -() => this; |
7 toString() => "5"; | 9 toString() => "5"; |
8 abs() => "correct"; | 10 abs() => "correct"; |
9 } | 11 } |
10 | 12 |
11 // This triggered a bug in Dart2Js: the speculative type optimization assigned | 13 // This triggered a bug in Dart2Js: the speculative type optimization assigned |
12 // type "number" to 'a' and then to '-a'. In the bailout version the type for | 14 // type "number" to 'a' and then to '-a'. In the bailout version the type for |
13 // 'a' was removed, but the type for '-a' was kept. | 15 // 'a' was removed, but the type for '-a' was kept. |
14 foo(a) => -(-a); | 16 foo(a) => -(-a); |
15 | 17 |
16 main() { | 18 main() { |
17 Expect.equals("correct", foo(new A()).abs()); | 19 Expect.equals("correct", foo(new A()).abs()); |
18 } | 20 } |
OLD | NEW |