| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // Test that we invalidate parameter type optimization in the presence | 4 // Test that we invalidate parameter type optimization in the presence |
| 5 // of optional parameters. | 5 // of optional parameters. |
| 6 | 6 |
| 7 import "package:expect/expect.dart"; | |
| 8 | |
| 9 class A { | 7 class A { |
| 10 void foo(bool firstInvocation, [a = 42, b = 'foo']) { | 8 void foo(bool firstInvocation, [a = 42, b = 'foo']) { |
| 11 if (firstInvocation) { | 9 if (firstInvocation) { |
| 12 Expect.isTrue(a is String); | 10 Expect.isTrue(a is String); |
| 13 Expect.isTrue(b is int); | 11 Expect.isTrue(b is int); |
| 14 } else { | 12 } else { |
| 15 Expect.isTrue(a is int); | 13 Expect.isTrue(a is int); |
| 16 Expect.isTrue(b is String); | 14 Expect.isTrue(b is String); |
| 17 } | 15 } |
| 18 } | 16 } |
| 19 } | 17 } |
| 20 | 18 |
| 21 test() { | 19 test() { |
| 22 // This call to [A.foo] will be in the queue after [A.foo] has been | 20 // This call to [A.foo] will be in the queue after [A.foo] has been |
| 23 // compiled with the optimistic type assumptions. | 21 // compiled with the optimistic type assumptions. |
| 24 new A().foo(false); | 22 new A().foo(false); |
| 25 } | 23 } |
| 26 | 24 |
| 27 main() { | 25 main() { |
| 28 test(); | 26 test(); |
| 29 // This call to [A.foo] will be the first in the queue, and dart2js | 27 // This call to [A.foo] will be the first in the queue, and dart2js |
| 30 // will optimize the method with these parameter types. | 28 // will optimize the method with these parameter types. |
| 31 new A().foo(true, 'bar', 42); | 29 new A().foo(true, 'bar', 42); |
| 32 } | 30 } |
| OLD | NEW |