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 "dart:_js_helper"; |
5 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
6 | 7 |
7 // Test to see if resolving a hidden native class's method interferes with | 8 // Test to see if resolving a hidden native class's method interferes with |
8 // subsequent resolving the subclass's method. This might happen if the | 9 // subsequent resolving the subclass's method. This might happen if the |
9 // superclass caches the method in the prototype, so shadowing the dispatcher | 10 // superclass caches the method in the prototype, so shadowing the dispatcher |
10 // stored on Object.prototype. | 11 // stored on Object.prototype. |
11 | 12 |
12 class A native "A" { | 13 @Native("A") |
| 14 class A { |
13 foo() => 'A.foo ${bar()}'; | 15 foo() => 'A.foo ${bar()}'; |
14 bar() => 'A.bar'; | 16 bar() => 'A.bar'; |
15 } | 17 } |
16 | 18 |
17 class B extends A native "B" { | 19 @Native("B") |
| 20 class B extends A { |
18 bar() => 'B.bar'; | 21 bar() => 'B.bar'; |
19 } | 22 } |
20 | 23 |
21 class C extends B native "C" { | 24 @Native("C") |
| 25 class C extends B { |
22 foo() => 'C.foo; super.foo = ${super.foo()}'; | 26 foo() => 'C.foo; super.foo = ${super.foo()}'; |
23 bar() => 'C.bar'; | 27 bar() => 'C.bar'; |
24 } | 28 } |
25 | 29 |
26 class D extends C native "D" { | 30 @Native("D") |
| 31 class D extends C { |
27 bar() => 'D.bar'; | 32 bar() => 'D.bar'; |
28 } | 33 } |
29 | 34 |
30 makeA() native; | 35 makeA() native; |
31 makeB() native; | 36 makeB() native; |
32 makeC() native; | 37 makeC() native; |
33 makeD() native; | 38 makeD() native; |
34 | 39 |
35 void setup() native """ | 40 void setup() native """ |
36 // This code is all inside 'setup' and so not accesible from the global scope. | 41 // This code is all inside 'setup' and so not accesible from the global scope. |
(...skipping 29 matching lines...) Expand all Loading... |
66 var a = makeA(); | 71 var a = makeA(); |
67 var b = makeB(); | 72 var b = makeB(); |
68 var c = makeC(); | 73 var c = makeC(); |
69 var d = makeD(); | 74 var d = makeD(); |
70 | 75 |
71 Expect.equals('A.foo A.bar', a.foo()); | 76 Expect.equals('A.foo A.bar', a.foo()); |
72 Expect.equals('A.foo B.bar', b.foo()); | 77 Expect.equals('A.foo B.bar', b.foo()); |
73 Expect.equals('C.foo; super.foo = A.foo C.bar', c.foo()); | 78 Expect.equals('C.foo; super.foo = A.foo C.bar', c.foo()); |
74 Expect.equals('C.foo; super.foo = A.foo D.bar', d.foo()); | 79 Expect.equals('C.foo; super.foo = A.foo D.bar', d.foo()); |
75 } | 80 } |
OLD | NEW |