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