@@ -117,9 +117,9 @@ Host app mode: $hostMode
117
117
macroExecutionStrategy == 'aot' ? 'exe' : 'jit-snapshot' ,
118
118
'--packages=.dart_tool/package_config.json' ,
119
119
'--enable-experiment=macros' ,
120
- bootstrapFile.uri.toFilePath (),
121
120
'-o' ,
122
121
kernelOutputFile.uri.toFilePath (),
122
+ bootstrapFile.uri.toFilePath (),
123
123
]);
124
124
125
125
if (buildSnapshotResult.exitCode != 0 ) {
@@ -150,31 +150,34 @@ Host app mode: $hostMode
150
150
for (var i = 1 ; i <= 111 ; i++ ) {
151
151
var _shouldLog = i == 1 || i == 11 || i == 111 ;
152
152
if (_shouldLog) _log ('Running DataClass macro for the ${i }th time' );
153
- if (instanceId.shouldExecute (DeclarationKind .clazz , Phase .types)) {
153
+ if (instanceId.shouldExecute (DeclarationKind .classType , Phase .types)) {
154
154
if (_shouldLog) _log ('Running types phase' );
155
155
var result = await executor.executeTypesPhase (
156
156
instanceId, myClass, SimpleIdentifierResolver ());
157
157
if (i == 1 ) results.add (result);
158
158
}
159
- if (instanceId.shouldExecute (DeclarationKind .clazz, Phase .declarations)) {
159
+ if (instanceId.shouldExecute (
160
+ DeclarationKind .classType, Phase .declarations)) {
160
161
if (_shouldLog) _log ('Running declarations phase' );
161
162
var result = await executor.executeDeclarationsPhase (
162
163
instanceId,
163
164
myClass,
164
165
SimpleIdentifierResolver (),
166
+ SimpleTypeDeclarationResolver (),
165
167
SimpleTypeResolver (),
166
- SimpleClassIntrospector ());
168
+ SimpleTypeIntrospector ());
167
169
if (i == 1 ) results.add (result);
168
170
}
169
- if (instanceId.shouldExecute (DeclarationKind .clazz, Phase .definitions)) {
171
+ if (instanceId.shouldExecute (
172
+ DeclarationKind .classType, Phase .definitions)) {
170
173
if (_shouldLog) _log ('Running definitions phase' );
171
174
var result = await executor.executeDefinitionsPhase (
172
175
instanceId,
173
176
myClass,
174
177
SimpleIdentifierResolver (),
178
+ SimpleTypeDeclarationResolver (),
175
179
SimpleTypeResolver (),
176
- SimpleClassIntrospector (),
177
- FakeTypeDeclarationResolver (),
180
+ SimpleTypeIntrospector (),
178
181
FakeTypeInferrer ());
179
182
if (i == 1 ) results.add (result);
180
183
}
@@ -189,7 +192,11 @@ Host app mode: $hostMode
189
192
var first111RunsEnd = _watch.elapsed;
190
193
191
194
_log ('Building augmentation library' );
192
- var library = executor.buildAugmentationLibrary (results, (identifier) {
195
+ var library = executor.buildAugmentationLibrary (
196
+ results,
197
+ (identifier) => identifier == myClass.identifier
198
+ ? myClass
199
+ : throw UnsupportedError ('Can only resolve myClass' ), (identifier) {
193
200
if (['bool' , 'Object' , 'String' , 'int' ].contains (identifier.name)) {
194
201
return ResolvedIdentifier (
195
202
kind: IdentifierKind .topLevelMember,
@@ -251,24 +258,34 @@ final stringType = NamedTypeAnnotationImpl(
251
258
isNullable: false ,
252
259
typeArguments: const []);
253
260
254
- final objectClass = ClassDeclarationImpl (
261
+ final objectClass = IntrospectableClassDeclarationImpl (
255
262
id: RemoteInstance .uniqueId,
256
263
identifier: objectIdentifier,
257
264
interfaces: [],
258
- isAbstract: false ,
259
- isExternal: false ,
265
+ hasAbstract: false ,
266
+ hasBase: false ,
267
+ hasExternal: false ,
268
+ hasFinal: false ,
269
+ hasInterface: false ,
270
+ hasMixin: false ,
271
+ hasSealed: false ,
260
272
mixins: [],
261
273
superclass: null ,
262
274
typeParameters: []);
263
275
264
276
final myClassIdentifier =
265
277
IdentifierImpl (id: RemoteInstance .uniqueId, name: 'MyClass' );
266
- final myClass = ClassDeclarationImpl (
278
+ final myClass = IntrospectableClassDeclarationImpl (
267
279
id: RemoteInstance .uniqueId,
268
280
identifier: myClassIdentifier,
269
281
interfaces: [],
270
- isAbstract: false ,
271
- isExternal: false ,
282
+ hasAbstract: false ,
283
+ hasBase: false ,
284
+ hasExternal: false ,
285
+ hasFinal: false ,
286
+ hasInterface: false ,
287
+ hasMixin: false ,
288
+ hasSealed: false ,
272
289
mixins: [],
273
290
superclass: NamedTypeAnnotationImpl (
274
291
id: RemoteInstance .uniqueId,
@@ -280,7 +297,7 @@ final myClass = ClassDeclarationImpl(
280
297
281
298
final myClassFields = [
282
299
FieldDeclarationImpl (
283
- definingClass : myClassIdentifier,
300
+ definingType : myClassIdentifier,
284
301
id: RemoteInstance .uniqueId,
285
302
identifier: IdentifierImpl (id: RemoteInstance .uniqueId, name: 'myString' ),
286
303
isExternal: false ,
@@ -289,7 +306,7 @@ final myClassFields = [
289
306
isStatic: false ,
290
307
type: stringType),
291
308
FieldDeclarationImpl (
292
- definingClass : myClassIdentifier,
309
+ definingType : myClassIdentifier,
293
310
id: RemoteInstance .uniqueId,
294
311
identifier: IdentifierImpl (id: RemoteInstance .uniqueId, name: 'myBool' ),
295
312
isExternal: false ,
@@ -301,7 +318,7 @@ final myClassFields = [
301
318
302
319
final myClassMethods = [
303
320
MethodDeclarationImpl (
304
- definingClass : myClassIdentifier,
321
+ definingType : myClassIdentifier,
305
322
id: RemoteInstance .uniqueId,
306
323
identifier: IdentifierImpl (id: RemoteInstance .uniqueId, name: '==' ),
307
324
isAbstract: false ,
@@ -328,7 +345,7 @@ final myClassMethods = [
328
345
typeParameters: [],
329
346
),
330
347
MethodDeclarationImpl (
331
- definingClass : myClassIdentifier,
348
+ definingType : myClassIdentifier,
332
349
id: RemoteInstance .uniqueId,
333
350
identifier: IdentifierImpl (id: RemoteInstance .uniqueId, name: 'hashCode' ),
334
351
isAbstract: false ,
@@ -343,7 +360,7 @@ final myClassMethods = [
343
360
typeParameters: [],
344
361
),
345
362
MethodDeclarationImpl (
346
- definingClass : myClassIdentifier,
363
+ definingType : myClassIdentifier,
347
364
id: RemoteInstance .uniqueId,
348
365
identifier: IdentifierImpl (id: RemoteInstance .uniqueId, name: 'toString' ),
349
366
isAbstract: false ,
@@ -366,26 +383,24 @@ abstract class Fake {
366
383
}
367
384
368
385
/// Returns data as if everything was [myClass] .
369
- class SimpleClassIntrospector extends Fake implements ClassIntrospector {
386
+ class SimpleTypeIntrospector implements TypeIntrospector {
370
387
@override
371
388
Future <List <ConstructorDeclaration >> constructorsOf (
372
- covariant ClassDeclaration clazz ) async =>
389
+ IntrospectableType type ) async =>
373
390
[];
374
391
375
392
@override
376
- Future <List <FieldDeclaration >> fieldsOf (
377
- covariant ClassDeclaration clazz) async =>
378
- clazz == myClass ? myClassFields : [];
393
+ Future <List <FieldDeclaration >> fieldsOf (IntrospectableType type) async =>
394
+ type == myClass ? myClassFields : [];
379
395
380
396
@override
381
- Future <List <MethodDeclaration >> methodsOf (
382
- covariant ClassDeclaration clazz) async =>
383
- clazz == myClass ? myClassMethods : [];
397
+ Future <List <MethodDeclaration >> methodsOf (IntrospectableType type) async =>
398
+ type == myClass ? myClassMethods : [];
384
399
385
400
@override
386
- Future <ClassDeclaration ?> superclassOf (
387
- covariant ClassDeclaration clazz ) async =>
388
- clazz == myClass ? objectClass : null ;
401
+ Future <List < EnumValueDeclaration >> valuesOf (
402
+ IntrospectableEnumDeclaration type ) async =>
403
+ [] ;
389
404
}
390
405
391
406
/// This is a very basic identifier resolver, it does no actual resolution.
@@ -396,8 +411,18 @@ class SimpleIdentifierResolver implements IdentifierResolver {
396
411
IdentifierImpl (id: RemoteInstance .uniqueId, name: name);
397
412
}
398
413
399
- class FakeTypeDeclarationResolver extends Fake
400
- implements TypeDeclarationResolver {}
414
+ class SimpleTypeDeclarationResolver implements TypeDeclarationResolver {
415
+ @override
416
+ Future <TypeDeclaration > declarationOf (covariant Identifier identifier) async {
417
+ if (identifier == myClass.identifier) {
418
+ return myClass;
419
+ } else if (identifier == objectClass.identifier) {
420
+ return objectClass;
421
+ } else {
422
+ throw UnsupportedError ('Could not resolve identifier ${identifier .name }' );
423
+ }
424
+ }
425
+ }
401
426
402
427
class FakeTypeInferrer extends Fake implements TypeInferrer {}
403
428
0 commit comments