@@ -44,7 +44,9 @@ Future<void> runBenchmarks(MacroExecutor executor, Uri macroUri) async {
4444 executor, macroUri, identifierResolver, instanceId);
4545 await typesBenchmark.report ();
4646 BuildAugmentationLibraryBenchmark .reportAndPrint (
47- executor, typesBenchmark.results, identifierDeclarations);
47+ executor,
48+ [if (typesBenchmark.result != null ) typesBenchmark.result! ],
49+ identifierDeclarations);
4850 final declarationsBenchmark = DataClassDeclarationsPhaseBenchmark (
4951 executor,
5052 macroUri,
@@ -54,7 +56,9 @@ Future<void> runBenchmarks(MacroExecutor executor, Uri macroUri) async {
5456 typeDeclarationResolver);
5557 await declarationsBenchmark.report ();
5658 BuildAugmentationLibraryBenchmark .reportAndPrint (
57- executor, declarationsBenchmark.results, identifierDeclarations);
59+ executor,
60+ [if (declarationsBenchmark.result != null ) declarationsBenchmark.result! ],
61+ identifierDeclarations);
5862 final definitionsBenchmark = DataClassDefinitionPhaseBenchmark (
5963 executor,
6064 macroUri,
@@ -64,7 +68,9 @@ Future<void> runBenchmarks(MacroExecutor executor, Uri macroUri) async {
6468 typeDeclarationResolver);
6569 await definitionsBenchmark.report ();
6670 BuildAugmentationLibraryBenchmark .reportAndPrint (
67- executor, definitionsBenchmark.results, identifierDeclarations);
71+ executor,
72+ [if (definitionsBenchmark.result != null ) definitionsBenchmark.result! ],
73+ identifierDeclarations);
6874}
6975
7076class DataClassInstantiateBenchmark extends AsyncBenchmarkBase {
@@ -86,19 +92,17 @@ class DataClassTypesPhaseBenchmark extends AsyncBenchmarkBase {
8692 final Uri macroUri;
8793 final IdentifierResolver identifierResolver;
8894 final MacroInstanceIdentifier instanceIdentifier;
89- late List < MacroExecutionResult > results ;
95+ MacroExecutionResult ? result ;
9096
9197 DataClassTypesPhaseBenchmark (this .executor, this .macroUri,
9298 this .identifierResolver, this .instanceIdentifier)
9399 : super ('DataClassTypesPhase' );
94100
95101 Future <void > run () async {
96- results = < MacroExecutionResult > [];
97102 if (instanceIdentifier.shouldExecute (
98103 DeclarationKind .classType, Phase .types)) {
99- var result = await executor.executeTypesPhase (
104+ result = await executor.executeTypesPhase (
100105 instanceIdentifier, myClass, identifierResolver);
101- results.add (result);
102106 }
103107 }
104108}
@@ -111,7 +115,7 @@ class DataClassDeclarationsPhaseBenchmark extends AsyncBenchmarkBase {
111115 final TypeIntrospector typeIntrospector;
112116 final TypeDeclarationResolver typeDeclarationResolver;
113117
114- late List < MacroExecutionResult > results ;
118+ MacroExecutionResult ? result ;
115119
116120 DataClassDeclarationsPhaseBenchmark (
117121 this .executor,
@@ -123,17 +127,16 @@ class DataClassDeclarationsPhaseBenchmark extends AsyncBenchmarkBase {
123127 : super ('DataClassDeclarationsPhase' );
124128
125129 Future <void > run () async {
126- results = < MacroExecutionResult > [] ;
130+ result = null ;
127131 if (instanceIdentifier.shouldExecute (
128132 DeclarationKind .classType, Phase .declarations)) {
129- var result = await executor.executeDeclarationsPhase (
133+ result = await executor.executeDeclarationsPhase (
130134 instanceIdentifier,
131135 myClass,
132136 identifierResolver,
133137 typeDeclarationResolver,
134138 SimpleTypeResolver (),
135139 typeIntrospector);
136- results.add (result);
137140 }
138141 }
139142}
@@ -146,7 +149,7 @@ class DataClassDefinitionPhaseBenchmark extends AsyncBenchmarkBase {
146149 final TypeIntrospector typeIntrospector;
147150 final TypeDeclarationResolver typeDeclarationResolver;
148151
149- late List < MacroExecutionResult > results ;
152+ MacroExecutionResult ? result ;
150153
151154 DataClassDefinitionPhaseBenchmark (
152155 this .executor,
@@ -158,18 +161,17 @@ class DataClassDefinitionPhaseBenchmark extends AsyncBenchmarkBase {
158161 : super ('DataClassDefinitionPhase' );
159162
160163 Future <void > run () async {
161- results = < MacroExecutionResult > [] ;
164+ result = null ;
162165 if (instanceIdentifier.shouldExecute (
163166 DeclarationKind .classType, Phase .definitions)) {
164- var result = await executor.executeDefinitionsPhase (
167+ result = await executor.executeDefinitionsPhase (
165168 instanceIdentifier,
166169 myClass,
167170 identifierResolver,
168171 typeDeclarationResolver,
169- SimpleTypeResolver (),
172+ const SimpleTypeResolver (),
170173 typeIntrospector,
171- FakeTypeInferrer ());
172- results.add (result);
174+ const FakeTypeInferrer ());
173175 }
174176 }
175177}
@@ -179,6 +181,7 @@ final myClassIdentifier =
179181final myClass = IntrospectableClassDeclarationImpl (
180182 id: RemoteInstance .uniqueId,
181183 identifier: myClassIdentifier,
184+ library: fooLibrary,
182185 interfaces: [],
183186 hasAbstract: false ,
184187 hasBase: false ,
@@ -201,6 +204,7 @@ final myClassFields = [
201204 definingType: myClassIdentifier,
202205 id: RemoteInstance .uniqueId,
203206 identifier: IdentifierImpl (id: RemoteInstance .uniqueId, name: 'myString' ),
207+ library: fooLibrary,
204208 isExternal: false ,
205209 isFinal: true ,
206210 isLate: false ,
@@ -210,6 +214,7 @@ final myClassFields = [
210214 definingType: myClassIdentifier,
211215 id: RemoteInstance .uniqueId,
212216 identifier: IdentifierImpl (id: RemoteInstance .uniqueId, name: 'myBool' ),
217+ library: fooLibrary,
213218 isExternal: false ,
214219 isFinal: true ,
215220 isLate: false ,
@@ -222,6 +227,7 @@ final myClassMethods = [
222227 definingType: myClassIdentifier,
223228 id: RemoteInstance .uniqueId,
224229 identifier: IdentifierImpl (id: RemoteInstance .uniqueId, name: '==' ),
230+ library: fooLibrary,
225231 isAbstract: false ,
226232 isExternal: false ,
227233 isGetter: false ,
@@ -233,6 +239,7 @@ final myClassMethods = [
233239 ParameterDeclarationImpl (
234240 id: RemoteInstance .uniqueId,
235241 identifier: IdentifierImpl (id: RemoteInstance .uniqueId, name: 'other' ),
242+ library: fooLibrary,
236243 isNamed: false ,
237244 isRequired: true ,
238245 type: NamedTypeAnnotationImpl (
@@ -249,6 +256,7 @@ final myClassMethods = [
249256 definingType: myClassIdentifier,
250257 id: RemoteInstance .uniqueId,
251258 identifier: IdentifierImpl (id: RemoteInstance .uniqueId, name: 'hashCode' ),
259+ library: fooLibrary,
252260 isAbstract: false ,
253261 isExternal: false ,
254262 isOperator: false ,
@@ -264,6 +272,7 @@ final myClassMethods = [
264272 definingType: myClassIdentifier,
265273 id: RemoteInstance .uniqueId,
266274 identifier: IdentifierImpl (id: RemoteInstance .uniqueId, name: 'toString' ),
275+ library: fooLibrary,
267276 isAbstract: false ,
268277 isExternal: false ,
269278 isGetter: false ,
0 commit comments