|
1 | 1 | # Augmentation Libraries
|
2 | 2 |
|
3 |
| -Author: [email protected], Version: 1. 0 |
| 3 | +Author: [email protected], Version: 1. 1 (see Changelog at end) |
4 | 4 |
|
5 | 5 | Augmentation libraries allow splitting a Dart library into files. Unlike part
|
6 | 6 | files, each augmentation has its [own imports][part imports] and top-level
|
@@ -148,6 +148,10 @@ merge its declarations into this library. It is a compile-time error if:
|
148 | 148 | * The library referenced in a `library augment` directive does not have an
|
149 | 149 | `import augment` directive pointing back to this augmentation.
|
150 | 150 |
|
| 151 | +* The same augmentation library is applied more than once. *In other words, |
| 152 | + you can't have redundant `import augment` directives that point to the same |
| 153 | + library.* |
| 154 | + |
151 | 155 | Since the main library and its augmentation both point to each other, these
|
152 | 156 | rules imply that a given augmentation file can only be used to augment a single
|
153 | 157 | library.
|
@@ -286,8 +290,10 @@ It is a compile-time error if:
|
286 | 290 | * The signature of the function augmentation does not exactly match the
|
287 | 291 | original function. This means the return types must be the same; there must
|
288 | 292 | be the same number of positional, optional, and named parameters; the types
|
289 |
| - of corresponding positional and optional parameters must be the same; and |
290 |
| - the names and types of named parameters must be the same. |
| 293 | + of corresponding positional and optional parameters must be the same; the |
| 294 | + names and types of named parameters must be the same; any type parameters |
| 295 | + and bounds must be the same; and any `required` or `covariant` modifiers |
| 296 | + must match. |
291 | 297 |
|
292 | 298 | * The original function is declared `external` and the augmenting function
|
293 | 299 | uses `augment super()`.
|
@@ -671,3 +677,15 @@ part files can do. At that point, we can more strongly recommend the few users
|
671 | 677 | using them migrate to augmentations. In Dart 3.0, we can consider removing
|
672 | 678 | support for part files entirely, which would simplify the language and our
|
673 | 679 | tools.
|
| 680 | + |
| 681 | +## Changelog |
| 682 | + |
| 683 | +### 1.1 |
| 684 | + |
| 685 | +* Make it an error to apply the same augmentation multiple times (#1957). |
| 686 | +* Clarify type parameters and parameter modifiers in function signature |
| 687 | + matching (#2059). |
| 688 | + |
| 689 | +### 1.0 |
| 690 | + |
| 691 | +Initial version. |
0 commit comments