@@ -210,7 +210,7 @@ import augment 'b.dart';
210
210
augment class C {}
211
211
212
212
augment void trace() {
213
- augment super.trace ();
213
+ augmented ();
214
214
print('a');
215
215
}
216
216
@@ -220,7 +220,7 @@ library augment 'a.dart';
220
220
class D {}
221
221
222
222
augment void trace() {
223
- augment super.trace ();
223
+ augmented ();
224
224
print('b');
225
225
}
226
226
@@ -230,12 +230,12 @@ library augment 'main.dart';
230
230
augment class D {}
231
231
232
232
augment void trace() {
233
- augment super.trace ();
233
+ augmented ();
234
234
print('c');
235
235
}
236
236
237
237
augment void trace() {
238
- augment super.trace ();
238
+ augmented ();
239
239
print('d');
240
240
}
241
241
```
@@ -284,12 +284,11 @@ Often, an augmentation wants to also preserve and run the code of the original
284
284
declaration it augments (hence the name "augmentation"). It may want run before
285
285
the original code, after it, or both. To allow that, we allow a new expression
286
286
syntax inside the bodies of augmenting members. Inside a member marked
287
- `augment`, an expression like `augment super` can be used to refer to the
288
- original function, getter, setter, or variable initializer. See the next
289
- section for a full specification of what `augment super` actually means,
290
- in the various contexts.
291
-
292
- **TODO: I'm not sold on `augment super`. Is there a better syntax?**
287
+ `augment`, the expression `augmented` can be used to refer to the original
288
+ function, getter, setter, or variable initializer. This is a contextual keyword
289
+ within `augment` members, and has no special meaning outside of that context.
290
+ See the next section for a full specification of what `augmented` actually
291
+ means, in the various contexts.
293
292
294
293
The same declaration can be augmented multiple times by separate augmentation
295
294
libraries. When that happens, the merge order defined previously determines
@@ -304,39 +303,43 @@ It is a compile-time error if:
304
303
original declaration occurs, according to merge order. *An augmentation
305
304
library can both declare a new declaration and augment it in the same file.*
306
305
307
- ### Augment super
306
+ ### Augmented Expression
308
307
309
- The exact result of an `augment super ` expression depends on what is being
308
+ The exact result of an `augmented ` expression depends on what is being
310
309
augmented, but it follows generally the same rules as any normal identifier:
311
310
312
- * **Augmenting getters**: Within an augmenting getter `augment super ` invokes
313
- the getter and evaluates to the return value. If augmenting a field with a
311
+ * **Augmenting getters**: Within an augmenting getter `augmented ` invokes the
312
+ getter and evaluates to the return value. If augmenting a field with a
314
313
getter, this will invoke the implicit getter from the augmented field.
315
314
316
- * **Augmenting setters**: Within an augmenting setter `augment super ` must be
315
+ * **Augmenting setters**: Within an augmenting setter `augmented ` must be
317
316
followed by an `=` and will directly invoke the augmented setter. If
318
317
augmenting a field with a setter, this will invoke the implicit setter from
319
318
the augmented field.
320
319
321
- * **Augmenting fields**: Within an augmenting field, `augment super ` can only
322
- be used in an initializer expression, and refers to the original field's
320
+ * **Augmenting fields**: Within an augmenting field, `augmented ` can only be
321
+ used in an initializer expression, and refers to the original field's
323
322
initializer expression, which is immediately evaluated.
324
323
325
- It is a compile-time error to use `augment super ` in an augmenting field's
324
+ It is a compile-time error to use `augmented ` in an augmenting field's
326
325
initializer if the member being augmented is not a field with an
327
326
initializer.
328
327
329
- * **Augmenting functions**: When augmenting a function, `augment super` refers
330
- to the augmented function. Tear offs are allowed.
328
+ * **Augmenting functions**: When augmenting a function, `augmented` refers to
329
+ the augmented function. Tear offs are not allowed, so this function must
330
+ immediately be invoked.
331
+
332
+ * **Augmenting operators**: When augmenting an operator, `augmented` must be
333
+ followed by the operator. For example when augmenting `+` you must do
334
+ `augmented + 1`, and when augmenting `[]` you must do `augmented[<arg>]`.
335
+ These constructs invoke the augmented operator, and are the only valid uses
336
+ of `augmented` in these contexts.
331
337
332
- * **Augmenting operators**: When augmenting an operator, `augment super` must
333
- be followed by the operator. For example when augmenting `+` you must do
334
- `augment super + 1`, and when augmenting `[]` you must do
335
- `augment super[<arg>]`. These constructs invoke the augmented operator, and
336
- are the only valid uses of `augment super` in these contexts.
338
+ * **Augmenting enum values**: When augmenting an enum value, `augmented` has
339
+ no meaning and is not allowed.
337
340
338
- * **Augmenting enum values**: When augmenting an enum value, `augment super`
339
- has no meaning and is not allowed .
341
+ In all relevant cases, if the augmented member is an instance member, it is
342
+ invoked with the same value for `this` .
340
343
341
344
### Augmenting types
342
345
@@ -414,23 +417,21 @@ augmented to wrap the original code in additional code:
414
417
// Wrap the original function in profiling:
415
418
augment int slowCalculation(int a, int b) {
416
419
var watch = Stopwatch()..start();
417
- var result = augment super (a, b);
420
+ var result = augmented (a, b);
418
421
print(watch.elapsedMilliseconds);
419
422
return result;
420
423
}
421
424
```
422
425
423
426
The augmentation replaces the original function body with the augmenting code.
424
- Inside the augmentation body, a special ` augment super ()` expression may be used
425
- to execute the original function body. That expression takes an argument list
427
+ Inside the augmentation body, a special ` augmented ()` expression may be used to
428
+ execute the original function body. That expression takes an argument list
426
429
matching the original function's parameter list and returns the function's
427
430
return type.
428
431
429
- ** TODO: Better syntax than ` augment super ` ?**
430
-
431
- The augmenting function does not have to pass the same arguments to `augment
432
- super()` as were passed to it. It may call it once, more than once, or not at
433
- all.
432
+ The augmenting function does not have to pass the same arguments to
433
+ ` augmented() ` as were passed to it. It may call it once, more than once, or not
434
+ at all.
434
435
435
436
It is a compile-time error if:
436
437
@@ -495,13 +496,13 @@ More specifically:
495
496
496
497
* ** Augmenting with a getter:** A getter in an augmentation library can
497
498
augment a getter in the main library or the implicit getter defined by a
498
- variable in the main library. Inside the augmenting body, an ` augment super `
499
+ variable in the main library. Inside the augmenting body, an ` augmented `
499
500
expression invokes the original getter.
500
501
501
502
* ** Augmenting with a setter:** A setter in an augmentation library can
502
503
augment a setter in the main library or the implicit setter defined by a
503
504
non-final variable in the main library. Inside the augmenting setter, an
504
- ` augment super =` expression invokes the original setter.
505
+ ` augmented =` expression invokes the original setter.
505
506
506
507
* ** Augmenting a getter and/or setter with a variable:** This is a
507
508
compile-time error in all cases. Augmenting an abstract or external variable
@@ -545,8 +546,8 @@ More specifically:
545
546
Since the initializer is the only meaningful part of the augmenting
546
547
declaration, an initializer must be provided. This augmenting initializer
547
548
replaces the original initializer. The augmenting initializer may use an
548
- ` augment super ` expression which executes the original initializer
549
- expression when evaluated.
549
+ ` augmented ` expression which executes the original initializer expression
550
+ when evaluated.
550
551
551
552
The ` late ` property of a variable must always be consistent between the
552
553
augmented variable and its augmenting variables.
@@ -563,13 +564,13 @@ It is a compile-time error if:
563
564
564
565
* The original and augmenting declarations do not have the same type.
565
566
566
- * An augmenting declaration uses ` augment super ` when the original declaration
567
- has no concrete implementation. Note that all external declarations are
568
- assumed to have an implementation provided by another external source, and
569
- they will throw a runtime exception when called if not.
567
+ * An augmenting declaration uses ` augmented ` when the original declaration has
568
+ no concrete implementation. Note that all external declarations are assumed
569
+ to have an implementation provided by another external source, and they will
570
+ throw a runtime exception when called if not.
570
571
571
- * An augmenting initializer uses ` augment super ` and the augmented variable
572
- is not a variable with an initializer.
572
+ * An augmenting initializer uses ` augmented ` and the augmented variable is not
573
+ a variable with an initializer.
573
574
574
575
* A final variable is augmented with a setter. (Instead, the augmentation
575
576
library can declare a * non-augmenting* setter that goes alongside the
@@ -652,7 +653,7 @@ body. If the augmenting constructor has any initializers, they are appended to
652
653
the original constructor's initializers, but before any original super
653
654
initializer or original redirecting initializer if there is one.
654
655
655
- In the augmenting constructor's body, an ` augment super ()` call invokes the
656
+ In the augmenting constructor's body, an ` augmented ()` call invokes the
656
657
original constructor's body.
657
658
658
659
It is a compile-time error if:
@@ -685,9 +686,9 @@ It is a compile-time error if:
685
686
686
687
When augmenting an ` external ` member, it is assumed that a real implementation
687
688
of that member has already been filled by some tool prior to any augmentations
688
- being applied. Thus, it is allowed to use ` augment super ` from augmenting
689
- members on external declarations, but it may throw a ` noSuchMethod ` error at
690
- runtime if no implementation was in fact provided.
689
+ being applied. Thus, it is allowed to use ` augmented ` from augmenting members
690
+ on external declarations, but it may throw a ` noSuchMethod ` error at runtime if
691
+ no implementation was in fact provided.
691
692
692
693
** NOTE** : Macros should _ not_ be able to statically tell if an external body has
693
694
been filled in by a compiler, because it could lead to a different result on
@@ -874,7 +875,7 @@ declaration ::= 'external' factoryConstructorSignature
874
875
| 'augment'? constructorSignature (redirection | initializers)?
875
876
```
876
877
877
- ** TODO: Define the grammar for the various ` augment super ` expressions.**
878
+ ** TODO: Define the grammar for the various ` augmented ` expressions.**
878
879
879
880
It is a compile-time error if:
880
881
@@ -951,8 +952,8 @@ To merge a set of declarations `D` into a namespace:
951
952
952
953
1 . Replace a matching variable, getter, and/or setter in the namespace
953
954
with the declaration. Inside the augmenting variable's initializer
954
- expression, an ` augment super ` expression invokes the original
955
- variable initializer.
955
+ expression, an ` augmented ` expression invokes the original variable
956
+ initializer.
956
957
957
958
## Documentation comments
958
959
@@ -979,6 +980,10 @@ language and our tools.
979
980
980
981
## Changelog
981
982
983
+ ## 1.14
984
+
985
+ * Change ` augment super ` to ` augmented ` .
986
+
982
987
## 1.13
983
988
984
989
* Clarify which clauses are (not) allowed in augmentations of certain
0 commit comments