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 interfaces and members | 116 * The annotation `@proxy` marks a class as implementing members dynamically |
117 * dynamically through `noSuchMethod`. | 117 * through `noSuchMethod`. |
118 * | 118 * |
119 * The annotation applies to any class. It is inherited by subclasses from both | 119 * The annotation applies to any class. It is inherited by subclasses from both |
120 * superclass and interfaces. | 120 * superclass and interfaces. |
121 * | 121 * |
122 * If a class is annotated with `@proxy`, or it implements any class that is | 122 * If a class is annotated with `@proxy`, or it implements any class that is |
123 * annotated, then the class is considered to implement any interface and | 123 * annotated, then the class is considered to implement any member with regard |
124 * any member with regard to static type analysis. As such, it is not a static | 124 * to static type analysis. |
125 * type warning to assign the object to a variable of any type, and it is not | 125 * As such, it is not a static type warning to access any member of the object |
126 * a static type warning to access any member of the object. | 126 * which is not implemented by the class, or to call a method with a different |
| 127 * number of parameters than it is declared with. |
127 * | 128 * |
128 * This only applies to static type warnings. The runtime type of the object | 129 * The annotation does not change which classes the annotated class implements, |
129 * is unaffected. It is not considered to implement any special interfaces at | 130 * and does not prevent static warnings for assigning an object to a variable |
130 * runtime, so assigning it to a typed variable may fail in checked mode, and | 131 * with a static type not implemented by the object. |
131 * testing it with the `is` operator will not work for any type except the | |
132 * ones it actually implements. | |
133 * | 132 * |
134 * Tools that understand `@proxy` should tell the user if a class using `@proxy` | 133 * The suppression of warnings only affect static type warnings about |
135 * does not override the `noSuchMethod` declared on [Object]. | 134 * member access. |
| 135 * The runtime type of the object is unaffected. |
| 136 * It is not considered to implement any special interfaces, |
| 137 * so assigning it to a typed variable may fail in checked mode, |
| 138 * and testing it with the `is` operator |
| 139 * will only return true for types it actually implements or extends. |
| 140 * Accessing a member which isn't implemented by the classs |
| 141 * will cause the `noSuchMethod` method to be called normally, |
| 142 * the `@proxy` annotation merely states the intent to handle (some of) those |
| 143 * `noSuchMethod` calls gracefully. |
| 144 * |
| 145 * A class that marked as `@proxy` should override the `noSuchMethod` |
| 146 * declared on [Object]. |
136 * | 147 * |
137 * The intent of the `@proxy` notation is to create objects that implement a | 148 * The intent of the `@proxy` notation is to create objects that implement a |
138 * type (or multiple types) that are not known at compile time. If the types | 149 * 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 | 150 * are known at compile time, a class can be written that implements these |
140 * types. | 151 * types. |
141 */ | 152 */ |
142 const Object proxy = const _Proxy(); | 153 const Object proxy = const _Proxy(); |
OLD | NEW |