Skip to content

Commit 178272e

Browse files
authored
define ordering of members during introspection (#3088)
closes #2157
1 parent 6c4a8f4 commit 178272e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

working/macros/feature-specification.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,21 @@ you to get the members of the class, as well as its entire class hierarchy.
580580

581581
[builder]: https://github.com/dart-lang/sdk/blob/main/pkg/_fe_analyzer_shared/lib/src/macros/api/builders.dart
582582

583+
### Introspection API ordering
584+
585+
Macros may produce code based on the order in which the introspection APIs
586+
return results. For instance when generating a constructor, a macro will likely
587+
just iterate over the fields and create a parameter for each.
588+
589+
We need generated augmentations to be identical on all platforms for all the
590+
same inputs, so we need to have a defined ordering when introspection apis are
591+
returning lists of declarations.
592+
593+
Therefore, whenever an implementation is returning a list of declarations, they
594+
should always be given in lexicographical order. We use lexicographical order
595+
instead of source text order, so that macro output does not have to be re-ran
596+
when re-ordering members.
597+
583598
### Introspecting on metadata annotations
584599

585600
Prior to macros, most use of metadata annotations in Dart was to guide code

0 commit comments

Comments
 (0)