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 // A native method prevents other members from having that name, including | 5 // A native method prevents other members from having that name, including |
6 // fields. However, native fields keep their name. The implication: a getter | 6 // fields. However, native fields keep their name. The implication: a getter |
7 // for the field must be based on the field's name, not the field's jsname. | 7 // for the field must be based on the field's name, not the field's jsname. |
8 | 8 |
9 interface I { | 9 interface I { |
10 int key; | 10 int key; |
11 } | 11 } |
12 | 12 |
13 @native("*A") | 13 @native("*A") |
14 class A implements I { | 14 class A implements I { |
15 int key; // jsname is 'key' | 15 int key; // jsname is 'key' |
16 int getKey() => key; | 16 int getKey() => key; |
17 } | 17 } |
18 | 18 |
19 class B implements I { | 19 class B implements I { |
20 int key; // jsname is not 'key' | 20 int key; // jsname is not 'key' |
21 B([this.key = 222]); | 21 B([this.key = 222]); |
22 int getKey() => key; | 22 int getKey() => key; |
23 } | 23 } |
24 | 24 |
25 @native("*X") | 25 @native("*X") |
26 class X { | 26 class X { |
27 @native('key') int native_key_method(); | 27 @native('key') int native_key_method(); |
28 // This should cause B.key to be renamed, but not A.key. | 28 // This should cause B.key to be renamed, but not A.key. |
29 @native('key') int key(); | 29 @native('key') int key(); |
30 } | 30 } |
31 | 31 |
32 @native A makeA(); | 32 @native A makeA(); |
33 @native X makeX(); | 33 @native X makeX(); |
34 | 34 |
35 | 35 |
36 @native(""" | 36 @native(""" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 Expect.equals(222, b.getKey()); | 87 Expect.equals(222, b.getKey()); |
88 } | 88 } |
89 | 89 |
90 main() { | 90 main() { |
91 setup(); | 91 setup(); |
92 | 92 |
93 testTyped(); | 93 testTyped(); |
94 testPartial(); | 94 testPartial(); |
95 testDynamic(); | 95 testDynamic(); |
96 } | 96 } |
OLD | NEW |