Skip to content

Commit 6feec76

Browse files
authored
specify that multiple augmentations of one declaration are allowed (#3370)
1 parent 47a849e commit 6feec76

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

working/augmentation-libraries/feature-specification.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ augmentations is recursively applied to the main library. The merge order is
185185
defined as a depth-first pre-order traversal of the `import augment` directives
186186
starting at the main library.
187187

188+
Within a single augmentation library, you may augment the same declaration
189+
multiple times, whether they are top level or nested declarations. The merge
190+
order of these is defined as the source order of the augmentations.
191+
188192
For example:
189193

190194
```
@@ -229,11 +233,16 @@ augment void trace() {
229233
augment super.trace();
230234
print('c');
231235
}
236+
237+
augment void trace() {
238+
augment super.trace();
239+
print('d');
240+
}
232241
```
233242

234243
The merge order is `main.dart`, `a.dart`, `b.dart`, then `c.dart`. The
235244
declarations in those libraries—new declarations or augmentations—
236-
are processed in that order.
245+
are processed in that order, and source order within that.
237246

238247
This order is user-visible in two ways:
239248

@@ -251,6 +260,7 @@ This order is user-visible in two ways:
251260
a
252261
b
253262
c
263+
d
254264
```
255265
256266
**TODO: Should it be a compile-time error if the main library and augmentation

0 commit comments

Comments
 (0)