|
1 | 1 | # Augmentation Libraries
|
2 | 2 |
|
3 | 3 |
|
4 |
| -Version: 1.10 (see [Changelog](#Changelog) at end) |
| 4 | +Version: 1.11 (see [Changelog](#Changelog) at end) |
5 | 5 |
|
6 | 6 | Augmentation libraries allow splitting a Dart library into files. Unlike part
|
7 | 7 | files, each augmentation has its [own imports][part imports] and top-level
|
@@ -266,6 +266,10 @@ syntactically mark a declaration as an augmentation of an existing one. The
|
266 | 266 | introduction of this new identifier will be language versioned in order to make
|
267 | 267 | it non-breaking for old code.
|
268 | 268 |
|
| 269 | +It is also allowed for a non-abstract class to have abstract members, if those |
| 270 | +members are filled in by an augmentation. This is primarily useful for macros, |
| 271 | +which may be used to provide a body for an abstract member. |
| 272 | +
|
269 | 273 | Often, an augmentation wants to also preserve and run the code of the original
|
270 | 274 | declaration it augments (hence the name "augmentation"). It may want run before
|
271 | 275 | the original code, after it, or both. To allow that, we allow a new expression
|
@@ -432,13 +436,6 @@ It is a compile-time error if:
|
432 | 436 | * The function augmentation specifies any default values. *Default values are
|
433 | 437 | defined solely by the original function.*
|
434 | 438 |
|
435 |
| -* The original function is declared `external` and the augmenting function |
436 |
| - uses `augment super()`. |
437 |
| - |
438 |
| - **TODO: Instead of making this an error, should we add a syntax that lets |
439 |
| - the augmentation dynamically detect whether there is an original body to |
440 |
| - wrap?** |
441 |
| - |
442 | 439 | **TODO: Should we allow augmenting functions to add parameters? If so, how does
|
443 | 440 | this interact with type checking calls to the function?**
|
444 | 441 |
|
@@ -518,15 +515,10 @@ More specifically:
|
518 | 515 | necessary to ensure that macros running after signatures are known can't
|
519 | 516 | change the signature of a declaration.*
|
520 | 517 |
|
521 |
| - **TODO: What if the augmenting variable doesn't have an initializer?** |
522 |
| - |
523 | 518 | It is a compile-time error if:
|
524 | 519 |
|
525 | 520 | * The original and augmenting declarations do not have the same type.
|
526 | 521 |
|
527 |
| -* An augmenting declaration uses `augment super` when the original declaration |
528 |
| - is marked `external`. |
529 |
| - |
530 | 522 | * An augmenting initializer uses `augment super` and the original declaration
|
531 | 523 | is not a variable with an initializer.
|
532 | 524 |
|
@@ -638,6 +630,21 @@ It is a compile-time error if:
|
638 | 630 |
|
639 | 631 | **TODO: What about redirecting constructors?**
|
640 | 632 |
|
| 633 | +### Augmenting external members |
| 634 | + |
| 635 | +When augmenting an `external` member, it is assumed that a real implementation |
| 636 | +of that member has already been filled by some tool prior to any augmentations |
| 637 | +being applied. Thus, it is allowed to use `augment super` from augmenting |
| 638 | +members on external declarations, but it may throw a `noSuchMethod` error at |
| 639 | +runtime if no implementation was in fact provided. |
| 640 | + |
| 641 | +**NOTE**: Macros should _not_ be able to statically tell if an external body has |
| 642 | +been filled in by a compiler, because it could lead to a different result on |
| 643 | +different platforms or tools. |
| 644 | + |
| 645 | +**TODO: Should we add a syntax to let the augmentation dynamically detect |
| 646 | +whether there is an external implementation to call?** |
| 647 | + |
641 | 648 | ### Metadata annotations and macro applications
|
642 | 649 |
|
643 | 650 | An augmentation declaration may have metadata annotations or macro applications.
|
@@ -921,6 +928,12 @@ language and our tools.
|
921 | 928 |
|
922 | 929 | ## Changelog
|
923 | 930 |
|
| 931 | +## 1.11 |
| 932 | + |
| 933 | +* Alter and clarify the semantics around augmenting external declarations. |
| 934 | +* Allow non-abstract classes to have implictly abstract members which are |
| 935 | + implemented in an augmentation. |
| 936 | + |
924 | 937 | ## 1.10
|
925 | 938 |
|
926 | 939 | * Make `augment` a built-in identifier.
|
|
0 commit comments