|
1 | 1 | # Augmentations
|
2 | 2 |
|
3 | 3 |
|
4 |
| -Version: 1.31 (see [Changelog](#Changelog) at end) |
| 4 | +Version: 1.32 (see [Changelog](#Changelog) at end) |
5 | 5 |
|
6 | 6 | Augmentations allow spreading your implementation across multiple locations,
|
7 | 7 | both within a single file and across multiple files. They can add new top-level
|
@@ -575,6 +575,10 @@ declaration, and if not `final`, also an abstract setter declaration. An
|
575 | 575 | `external` setter. Unlike abstract declarations, they are considered to
|
576 | 576 | have a concrete implementation.
|
577 | 577 |
|
| 578 | +Variables which require an initializer expression (such as those which have a |
| 579 | +non-nullable type and are not marked `late`) need not initially be defined |
| 580 | +with one, as long as there exists some augmentation which supplies it. |
| 581 | + |
578 | 582 | Augmentations on variables, getters, and setters works mostly at the level of
|
579 | 583 | these separate capabilities. For example, augmenting a variable with a getter
|
580 | 584 | replaces the augmented variable's implicit getter body with the augmenting
|
@@ -650,10 +654,11 @@ More specifically:
|
650 | 654 | usual, external and abstract variables cannot augment their
|
651 | 655 | initializing expression, since it does not exist.*
|
652 | 656 |
|
653 |
| - Augmenting initializer expressions replace the augmented initializer. The |
654 |
| - augmenting initializer may use an `augmented` expression which executes the |
655 |
| - augmented initializer expression when evaluated. If no initializer is |
656 |
| - provided then the augmented initializer is not altered. |
| 657 | + Augmenting initializer expressions replace the augmented initializer (or |
| 658 | + provide one where none existed previously). The augmenting initializer |
| 659 | + may use an `augmented` expression which executes the augmented initializer |
| 660 | + expression (if present) when evaluated. If no initializer is provided then |
| 661 | + the augmented initializer is not altered. |
657 | 662 |
|
658 | 663 | The `late` property of a variable must always be consistent between the
|
659 | 664 | augmented variable and its augmenting variables.
|
@@ -683,7 +688,9 @@ It is a **compile-time error** if:
|
683 | 688 |
|
684 | 689 | * An augmenting variable’s initializing expression uses `augmented`, and
|
685 | 690 | the stack of augmented declarations do not include a variable with an
|
686 |
| - initializing expression. |
| 691 | + explicit initializing expression. For nullable fields, the implicit null |
| 692 | + initialization only happens if there is no explicit initializer after the |
| 693 | + entire stack of augmentations has been applied. |
687 | 694 |
|
688 | 695 | * A non-writable variable declaration is augmented with a setter. (Instead,
|
689 | 696 | the author can declare a *non-augmenting* setter that goes alongside the
|
@@ -1393,6 +1400,13 @@ to the augmentation.
|
1393 | 1400 |
|
1394 | 1401 | ## Changelog
|
1395 | 1402 |
|
| 1403 | +### 1.32 |
| 1404 | + |
| 1405 | +* Specify that variables which require an initializer can have it defined |
| 1406 | + in any augmentation. |
| 1407 | +* Specify that the implicit null initialization is not applied until after |
| 1408 | + augmentation. |
| 1409 | + |
1396 | 1410 | ### 1.31
|
1397 | 1411 |
|
1398 | 1412 | * Specify that it is an error to have a static and instance member with the
|
|
0 commit comments