Skip to content

Commit

Permalink
specify that multiple augmentations of one declaration are allowed (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jakemac53 authored Sep 26, 2023
1 parent 47a849e commit 6feec76
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion working/augmentation-libraries/feature-specification.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ augmentations is recursively applied to the main library. The merge order is
defined as a depth-first pre-order traversal of the `import augment` directives
starting at the main library.

Within a single augmentation library, you may augment the same declaration
multiple times, whether they are top level or nested declarations. The merge
order of these is defined as the source order of the augmentations.

For example:

```
Expand Down Expand Up @@ -229,11 +233,16 @@ augment void trace() {
augment super.trace();
print('c');
}
augment void trace() {
augment super.trace();
print('d');
}
```

The merge order is `main.dart`, `a.dart`, `b.dart`, then `c.dart`. The
declarations in those libraries—new declarations or augmentations—
are processed in that order.
are processed in that order, and source order within that.

This order is user-visible in two ways:

Expand All @@ -251,6 +260,7 @@ This order is user-visible in two ways:
a
b
c
d
```

**TODO: Should it be a compile-time error if the main library and augmentation
Expand Down

0 comments on commit 6feec76

Please sign in to comment.