@@ -269,7 +269,9 @@ declaration it augments (hence the name "augmentation"). It may want run before
269
269
the original code, after it, or both. To allow that, we allow a new expression
270
270
syntax inside the bodies of augmenting members. Inside a member marked
271
271
`augment`, an expression like `augment super` can be used to refer to the
272
- original function, getter, setter, or variable initializer.
272
+ original function, getter, setter, or variable initializer. See the next
273
+ section for a full specification of what `augment super` actually means,
274
+ in the various contexts.
273
275
274
276
**TODO: I'm not sold on `augment super`. Is there a better syntax?**
275
277
@@ -286,6 +288,43 @@ It is a compile-time error if:
286
288
original declaration occurs, according to merge order. *An augmentation
287
289
library can both declare a new declaration and augment it in the same file.*
288
290
291
+ ### Augment super
292
+
293
+ The exact result of an `augment super` expression depends on what is being
294
+ augmented, but it follows generally the same rules as any normal identifier:
295
+
296
+ * **Augmenting getters**: Within an augmenting getter `augment super` invokes
297
+ the getter and evaluates to the return value. If augmenting a field with a
298
+ getter, this will invoke the implicit getter from the augmented field.
299
+
300
+ * **Augmenting setters**: Within an augmenting setter `augment super` must be
301
+ followed by an `=` and will directly invoke the augmented setter. If
302
+ augmenting a field with a setter, this will invoke the implicit setter from
303
+ the augmented field.
304
+
305
+ * **Augmenting fields**: Within an augmenting field, `augment super` can only
306
+ be used in an initializer expression, and refers to the original field's
307
+ initializer expression, which is immediately evaluated.
308
+
309
+ It is a compile-time error to use `augment super` in an augmenting field's
310
+ initializer if the member being augmented is not a field with an
311
+ initializer.
312
+
313
+ **TODO:** Define the behavior when a field is augmented by a getter or
314
+ setter, and then later again by a field.
315
+
316
+ * **Augmenting functions**: When augmenting a function, `augment super` refers
317
+ to the augmented function. Tear offs are allowed.
318
+
319
+ * **Augmenting operators**: When augmenting an operator, `augment super` must
320
+ be followed by the operator. For example when augmenting `+` you must do
321
+ `augment super + 1`, and when augmenting `[]` you must do
322
+ `augment super[<arg>]`. These constructs invoke the augmented operator, and
323
+ are the only valid uses of `augment super` in these contexts.
324
+
325
+ * **Augmenting enum values**: When augmenting an enum value, `augment super`
326
+ has no meaning and is not allowed.
327
+
289
328
### Augmenting types
290
329
291
330
A class, mixin, enum, or extension declaration can be marked with an `augment`
0 commit comments