Skip to content

Commit a594308

Browse files
authored
add ordering section on superclasses (#1972)
Closes #1938
1 parent 22ef7f2 commit a594308

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

working/macros/feature-specification.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,37 @@ order of macros:
154154
155155
Here, the macros applied to C are run `first`, `second`, then `third`.
156156
157+
* **Macros are applied to superclasses, mixins, and interfaces first, in**
158+
**Phase 2** For example:
159+
160+
```dart
161+
@third
162+
class B extends A with C implements D {}
163+
164+
@second
165+
class A implements C {}
166+
167+
@first
168+
class C {}
169+
170+
@first
171+
class D {}
172+
```
173+
174+
Here, the macros on `A`, `C` and `D` run before the macros on `B`, and `C`
175+
also runs before `A`. But otherwise the ordering is not defined (it is not
176+
observable).
177+
178+
This only applies to Phase 2, because it is the only phase where the order
179+
would be observable. In particular this allows macros running on `B` to see
180+
any members added to its super classes, mixins, or interfaces, by other
181+
macros running in phase 2.
182+
157183
Aside from these rules, macro introspection is limited so that evaluation order
158184
is not user visible. For example, if two macros are applied to two methods in
159185
the same class, there is no way for those macros to interfere with each other
160186
such that the application order can be detected.
161187
162-
**TODO*: Are superclass macros run before subclasses (#1938)?
163-
164188
## Phases
165189
166190
Before we can get into how macro authors create macros, there is another

0 commit comments

Comments
 (0)