@@ -122,15 +122,24 @@ Future<void> testAOT(String dillPath,
122122 .toSet ()
123123 .containsAll (['snapshot_data' , 'objects' , 'metadata' ]));
124124
125- final objects = (analyzerJson['objects' ] as List ).map ((o) => o as Map );
125+ final objects = (analyzerJson['objects' ] as List ).map ((o) => o as Map ).toList ();
126+ final classes = objects.where ((o) => o['type' ] == 'Class' ).toList ();
127+ final classnames = < int , String > {};
128+ final superclass = < int , int > {};
129+ final implementedInterfaces = < int , List <int >> {};
130+ for (final klass in classes) {
131+ final id = klass['id' ];
132+ superclass[id] = klass['super_class' ] as int ;
133+ classnames[id] = klass['name' ];
134+ implementedInterfaces[id] = [
135+ for (final superTypeId in klass['interfaces' ] as List ? ?? [])
136+ objects[superTypeId]['type_class' ]! ,
137+ ];
138+ }
126139
127140 // Find MethodChannel class.
128- final objList = objects
129- .where ((o) => o['type' ] == 'Class' && o['name' ] == 'MethodChannel' )
130- .toList ();
131- Expect .isTrue (
132- objList.length == 1 , 'one MethodChannel class must exist in output' );
133- final int objId = objList.first['id' ];
141+ final methodChannelId =
142+ classnames.entries.singleWhere ((e) => e.value == 'MethodChannel' ).key;
134143
135144 // Find string instance.
136145 final stringList = objects
@@ -144,16 +153,28 @@ Future<void> testAOT(String dillPath,
144153 final instanceList = objects
145154 .where ((o) =>
146155 o['type' ] == 'Instance' &&
147- o['class' ] == objId &&
156+ o['class' ] == methodChannelId &&
148157 o['references' ].contains (stringObjId))
149158 .toList ();
150- Expect .isTrue (instanceList.length == 1 , '''one instance of MethodChannel
159+ Expect .isTrue (instanceList.length == 1 , '''one instance of MethodChannel
151160 with reference to "constChannel1" must exist in output''' );
152161
162+ // Test class hierarchy information
163+ final myBaseClassId =
164+ classnames.entries.singleWhere ((e) => e.value == 'MyBase' ).key;
165+ final mySubClassId =
166+ classnames.entries.singleWhere ((e) => e.value == 'MySub' ).key;
167+ final myInterfaceClassId =
168+ classnames.entries.singleWhere ((e) => e.value == 'MyInterface' ).key;
169+
170+ Expect .equals (myBaseClassId, superclass[mySubClassId]);
171+ Expect .equals (myInterfaceClassId, implementedInterfaces[mySubClassId]! .single);
172+
153173 Expect .isTrue (analyzerJson['metadata' ].containsKey ('analyzer_version' ),
154174 'snapshot analyzer version must be reported' );
155175 Expect .isTrue (analyzerJson['metadata' ]['analyzer_version' ] == 2 ,
156176 'invalid snapshot analyzer version' );
177+
157178 });
158179}
159180
0 commit comments