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 // Test to see if resolving a hidden native class's method interferes with | 5 // Test to see if resolving a hidden native class's method interferes with |
6 // subsequent resolving the subclass's method. This might happen if the | 6 // subsequent resolving the subclass's method. This might happen if the |
7 // superclass caches the method in the prototype, so shadowing the dispatcher | 7 // superclass caches the method in the prototype, so shadowing the dispatcher |
8 // stored on Object.prototype. | 8 // stored on Object.prototype. |
9 | 9 |
10 // Version 1: It might be possible to call foo directly. | 10 // Version 1: It might be possible to call foo directly. |
11 @native("*A1") | 11 @native("*A1") |
12 class A1 { | 12 class A1 { |
13 @native foo(); | 13 @native foo(); |
14 } | 14 } |
15 | 15 |
16 @native("*B1") | 16 @native("*B1") |
17 class B1 extends A1 { | 17 class B1 extends A1 { |
18 @native foo(); | 18 @native foo(); |
19 } | 19 } |
20 | 20 |
21 @native makeA1(); | 21 @native makeA1(); |
22 @native makeB1(); | 22 @native makeB1(); |
23 | 23 |
24 | 24 |
25 // Version 2: foo needs some kind of trampoline. | 25 // Version 2: foo needs some kind of trampoline. |
26 @native("*A2") | 26 @native("*A2") |
27 class A2 { | 27 class A2 { |
28 @native foo([a=99]); | 28 @native foo([a=99]); |
29 } | 29 } |
30 | 30 |
31 @native("*B2") | 31 @native("*B2") |
32 class B2 extends A2 { | 32 class B2 extends A2 { |
33 @native foo([z=1000]); | 33 @native foo([z=1000]); |
34 } | 34 } |
35 | 35 |
36 @native makeA2(); | 36 @native makeA2(); |
37 @native makeB2(); | 37 @native makeB2(); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 caught = false; | 97 caught = false; |
98 try { | 98 try { |
99 var x = 123; | 99 var x = 123; |
100 x.foo(20); | 100 x.foo(20); |
101 } catch (ex) { | 101 } catch (ex) { |
102 caught = true; | 102 caught = true; |
103 Expect.isTrue(ex is NoSuchMethodError); | 103 Expect.isTrue(ex is NoSuchMethodError); |
104 } | 104 } |
105 Expect.isTrue(caught, "x.foo(20) should throw"); | 105 Expect.isTrue(caught, "x.foo(20) should throw"); |
106 } | 106 } |
OLD | NEW |