@@ -150,7 +150,7 @@ Summarizing the above, the requirements are:
150150* Let macros introspect over declarations in known libraries for things like
151151 subtype tests.
152152* Enable the Dart compiler to statically understand the library dependency
153- graph of the program.
153+ graph of the program before executing any macros .
154154* Allow macros to refer to declarations even in libraries that can't be run
155155 in the macro execution environment.
156156
@@ -232,10 +232,11 @@ In order to introspect over a declaration from a reflected import, the
232232` Identifier ` must first be resolved to a declaration. The [ macro introspection
233233API exposes] [ api ] methods to do that.
234234
235- ** TODO: Are these only available in certain phases? Can reflected imports be
236- resolved in any phase? Once resolved, can they be deeply reflected over (i.e.
237- walking the members of a class, etc.) or only used for things like subtype
238- tests?**
235+ The rules for introspection on identifiers from reflected imports are the same
236+ as other identifiers a macro might encounter. This means you cannot navigate
237+ to type declarations until after the types phase, and you cannot navigate to
238+ other declarations until after the declarations phase. All type declarations
239+ will also not be introspectable until the definitions phase.
239240
240241** TODO: Would be good to show a concrete example of a macro using a reflected
241242import and introspecting over it in a subtype test.**
@@ -270,8 +271,13 @@ a distinct Dart "platform" and only it supports reflected imports. When
270271targeting any other execution environment, a Dart compiler reports a
271272compile-time error if it encounters a reflected import.
272273
273- ** TODO: What about unit tests for macros? They presumably run in the normal
274- command line VM execution environment. Can they use reflected imports?**
274+ ** TODO: How can we enforce this compile time restriction when macros
275+ themselves are imported via normal imports? Do we need something like
276+ https://github.com/dart-lang/language/pull/1831 ?**
277+
278+ This also means that macros cannot be _ unit tested_ . That is, you cannot
279+ import, instantiate, and execute them as at runtime in the normal VM
280+ environment (or any other normal runtime environment).
275281
276282### Config-specific imports
277283
@@ -289,7 +295,9 @@ configuration either.)
289295
290296Thus, when determining what declarations are available for a reflected import,
291297** the compiler always uses the default URI for any config-specific imports or
292- exports that it encounters.**
298+ exports that it encounters.** . This may result in generating code which is not
299+ actually compatible with all platforms, if the API differs across the
300+ configuration specific imports.
293301
294302** TODO: Consider making it a compile-time error for a reflected import to
295303having any config-specific imports, directly or transitively?**
0 commit comments