@@ -142,9 +142,9 @@ more of the macro interfaces, then the annotation is treated as an application
142
142
of the ` myCoolMacro ` macro to the class MyClass.
143
143
144
144
Macro applications can also be passed arguments, either in the form of
145
- [ Code] [ ] expressions, [ Identifier ] [ ] s, or certain types of literal values. See
146
- [ Macro Arguments] ( #Macro-arguments ) for more information on how these arguments
147
- are handled when executing macros.
145
+ [ Code] [ ] expressions, [ TypeAnnotation ] [ ] s, or certain
146
+ types of literal values. See [ Macro Arguments] ( #Macro-arguments ) for more
147
+ information on how these arguments are handled when executing macros.
148
148
149
149
### Code Arguments
150
150
@@ -176,9 +176,9 @@ Most of the time, like here, a macro takes the arguments you pass it and
176
176
interpolates them back into code that it generates, so passing the arguments as
177
177
code is what you want.
178
178
179
- ### Identifier arguments
179
+ ### Type annotation arguments
180
180
181
- If you want to be able to introspect on an identifier passed in to you , you can
181
+ If you want to be able to introspect on a type passed in as an argument , you can
182
182
do that as well, consider the following:
183
183
184
184
``` dart
@@ -861,6 +861,7 @@ that top level declaration and insert that into the generated code.
861
861
** TODO: Define this API. See [ here] ( https://github.com/dart-lang/language/pull/1779#discussion_r683843130 ) .**
862
862
863
863
[ Identifier ] : https://github.com/dart-lang/sdk/blob/main/pkg/_fe_analyzer_shared/lib/src/macros/api/introspection.dart#L15
864
+ [ TypeAnnotation ] : https://github.com/dart-lang/sdk/blob/main/pkg/_fe_analyzer_shared/lib/src/macros/api/introspection.dart#L22
864
865
865
866
### Generating macro applications
866
867
@@ -1104,8 +1105,9 @@ it specifies through parameter types:
1104
1105
expression is automatically converted to a corresponding ` Code ` instance.
1105
1106
These provided code expressions may contain identifiers.
1106
1107
1107
- * If the parameter type is ` Identifier ` then a single identifier must be
1108
- passed, and it will be converted to a corresponding ` Identifier ` instance.
1108
+ * If the parameter type is ` TypeAnnotation ` then a literal type must be
1109
+ passed, and it will be converted to a corresponding ` TypeAnnotation `
1110
+ instance.
1109
1111
1110
1112
Note that this implicit lifting of the argument expression only happens when
1111
1113
the macro constructor is invoked through a macro application. If a macro
@@ -1115,19 +1117,18 @@ macro), then the caller is responsible for creating the Code object.
1115
1117
As usual, it is a compile-time error if the type of any argument value (which
1116
1118
may be a Code object) is not a subtype of the corresponding parameter type.
1117
1119
1118
- It is a compile-time error if an macro class constructor invoked by a macro
1119
- application has a parameter whose type is not Code ( or any subtype of it) or
1120
- one of the aforementioned primitive types (or a nullable type of any of those).
1120
+ It is a compile-time error if a macro class constructor invoked by a macro
1121
+ application has a parameter whose type is not Code, TypeAnnotation, or one of
1122
+ the aforementioned primitive types (or a nullable type of any of those).
1121
1123
1122
1124
#### Identifier Scope
1123
1125
1124
1126
The following rules apply to any ` Identifier ` passed as an argument to a macro
1125
- application, whether as a part of a ` Code ` expression or directly as an
1126
- ` Identifier ` instance.
1127
+ application, whether as a part of a ` Code ` expression or ` TypeAnnotation ` .
1127
1128
1128
- The scope of any ` Identifier ` argument is the same as the scope in which the
1129
- identifier appears in the source code, which is the same as the argument scope
1130
- for a metadata annotation on a declaration. This means:
1129
+ The scope of any ` Identifier ` is the same as the scope in which the identifier
1130
+ appears in the source code, which is the same as the argument scope for a
1131
+ metadata annotation on a declaration. This means:
1131
1132
1132
1133
* Identifiers in macro application arguments may only refer to static and top
1133
1134
level members.
0 commit comments