OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 part of dart.core; | 5 part of dart.core; |
6 | 6 |
7 /** | 7 /** |
8 * The annotation `@Deprecated('expires when')` marks a feature as deprecated. | 8 * The annotation `@Deprecated('expires when')` marks a feature as deprecated. |
9 * | 9 * |
10 * The annotation `@deprecated` is a shorthand for deprecating until | 10 * The annotation `@deprecated` is a shorthand for deprecating until |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 * For example, the annotation is intentionally not used in the Dart platform | 106 * For example, the annotation is intentionally not used in the Dart platform |
107 * libraries, since they only depend on themselves. | 107 * libraries, since they only depend on themselves. |
108 */ | 108 */ |
109 const Object override = const _Override(); | 109 const Object override = const _Override(); |
110 | 110 |
111 class _Proxy { | 111 class _Proxy { |
112 const _Proxy(); | 112 const _Proxy(); |
113 } | 113 } |
114 | 114 |
115 /** | 115 /** |
116 * The annotation `@proxy` marks a class as implementing members through | 116 * The annotation `@proxy` marks a class as implementing interfaces and members |
117 * `noSuchMethod`. | 117 * dynamically through `noSuchMethod`. |
118 * | 118 * |
119 * The annotation applies to concrete classes. It is not inherited by | 119 * The annotation applies to any class. It is inherited by subclasses from both |
120 * subclasses. | 120 * superclass and interfaces. |
121 * | 121 * |
122 * The marked class is considerer to implement any method, getter or setter | 122 * If a class is annotated with `@proxy`, or it implements any class that is |
123 * declared by its interface, even if there is no implementation in the | 123 * annotated, then the class is considered to implement any interface and |
124 * class. It will not generate the warning that is otherwise specified for an | 124 * any member with regard to static type analysis. As such, it is not a static |
125 * unimplemented method in a non-abstract class. | 125 * type warning to assign the object to a variable of any type, and it is not |
| 126 * a static type warning to access any member of the object. |
| 127 * |
| 128 * This only applies to static type warnings. The runtime type of the object |
| 129 * is unaffected. It is not considered to implement any special interfaces at |
| 130 * runtime, so assigning it to a typed variable may fail in checked mode, and |
| 131 * testing it with the `is` operator will not work for any type except the |
| 132 * ones it actually implements. |
126 * | 133 * |
127 * Tools that understand `@proxy` should tell the user if a class using `@proxy` | 134 * Tools that understand `@proxy` should tell the user if a class using `@proxy` |
128 * does not override the `noSuchMethod` declared on [Object]. | 135 * does not override the `noSuchMethod` declared on [Object]. |
129 * | 136 * |
130 * The intent of the `@proxy` notation is to avoid irrelevant warnings when | 137 * The intent of the `@proxy` notation is to create objects that implement a |
131 * a class implements its interface through `noSuchMethod`. | 138 * type (or multiple types) that are not known at compile time. If the types |
| 139 * are known at compile time, a class can be written that implements these |
| 140 * types. |
132 */ | 141 */ |
133 const Object proxy = const _Proxy(); | 142 const Object proxy = const _Proxy(); |
OLD | NEW |