Skip to content

Commit d16d1e5

Browse files
committed
Allow augmenting the same declaration multiple times.
Also a few other tweaks and typo fixes.
1 parent 61748c9 commit d16d1e5

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

working/augmentation-libraries/feature-specification.md

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ may themselves contain `import augment` directives. The entire tree of
157157
augmentations is recursively applied to the main library. In most cases, the
158158
order that augmentations are applied doesn't matter, but it is visible in a
159159
couple of corners where the merge process involves "appending". For those cases,
160-
merge order is defined as an in-order traversal of the `import augment`
161-
directives in the main library and its augmentations. So, in:
160+
merge order is defined as a depth-first pre-order traversal of the `import
161+
augment` directives in the main library and its augmentations. So, in:
162162

163163
```
164164
// main.dart
@@ -202,6 +202,10 @@ original function, getter, setter, or variable initializer.
202202

203203
**TODO: I'm not sold on `augment super`. Is there a better syntax?**
204204

205+
The same declaration can be augmented multiple times by separate augmentation
206+
libraries. When that happens, the merge order defined previously determines
207+
which order the wrapping is applied.
208+
205209
### Augmenting types
206210

207211
A class, mixin, or extension declaration can be marked with an `augment`
@@ -248,8 +252,8 @@ It is a compile-time error if:
248252
**TODO: We could consider allowing an `extends` clause if the main
249253
declaration doesn't have one.**
250254

251-
* The augmenting type is marked `abstract` and the corresponding type is not
252-
or vice versa.
255+
* The augmenting type is marked `abstract`. The main library determines
256+
whether the class is abstract or not.
253257

254258
### Augmenting functions
255259

@@ -292,11 +296,6 @@ It is a compile-time error if:
292296
the augmentation dynamically detect whether there is an original body to
293297
wrap?**
294298

295-
* If multiple augmenting libraries augment the same original function.
296-
297-
**TODO: Should we allow this? The order is defined, so we could let them
298-
nest arbitrarily deeply.**
299-
300299
**TODO: Should we allow augmenting functions to add parameters? If so, how does
301300
this interact with type checking calls to the function?**
302301

@@ -380,10 +379,6 @@ It is a compile-time error if:
380379
* An augmenting initializer uses `augment super` and the original declaration
381380
is not a variable with an initializer.
382381

383-
* Multiple augmenting libraries augment the same variable or getter/setter
384-
pair. Of course, one augmenting library may explicitly augment both a getter
385-
and setter with the same name.
386-
387382
* A final variable is augmented with a setter. (Instead, the augmentation
388383
library can declare a *non-augmenting* setter that goes alongside the
389384
implicit getter defined by the final variable.)
@@ -600,7 +595,7 @@ To apply an augmentation to the main library:
600595

601596
1. For each public declaration in the augmentation:
602597

603-
**TODO: If we allow private imports, update this allow merging private
598+
**TODO: If we allow private imports, update this allow to merging private
604599
declarations whose name matches a declaration in the main library.**
605600

606601
1. Merge the declaration into the main library's top-level namespace using

0 commit comments

Comments
 (0)