Skip to content

Commit

Permalink
Make it an error to generate macro applications that apply to previou…
Browse files Browse the repository at this point in the history
…s phases (#3214)

Related to #1931 and #1908
  • Loading branch information
jakemac53 authored Jul 13, 2023
1 parent b1b4828 commit 35c9062
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions working/macros/feature-specification.md
Original file line number Diff line number Diff line change
Expand Up @@ -897,18 +897,19 @@ implement their own declarations (#1908).

#### Adding macro applications to new declarations

When creating [Code][] instances, a macro may generate code which includes
When creating [DeclarationCode][] instances, a macro may generate code which includes
macro applications. These macro applications must be from either the current
phase or a later phase, but cannot be from previous phases.

If a macro application is added which implements an earlier phase, that phase
is not ran. This should result in a warning if the macro does not also
implement some phase that will be ran.
It is an error for a macro application to be added which would have applied to
its declaration in an earlier phase.

If a macro application is added which runs in the same phase as the current
one, then it is immediately expanded after execution of the current macro,
following the normal ordering rules.

[DeclarationCode]: https://github.com/dart-lang/sdk/blob/main/pkg/_fe_analyzer_shared/lib/src/macros/api/code.dart#L37

#### Ordering violations

Both of these mechanisms allow for normal macro ordering to be circumvented.
Expand Down

0 comments on commit 35c9062

Please sign in to comment.