@@ -99,29 +99,28 @@ abstract class InheritingContainer extends Container {
9999 ...typeParameters,
100100 ];
101101
102+ @visibleForTesting
102103 Iterable <Method > get inheritedMethods {
103104 var methodNames = declaredMethods.map ((m) => m.element.name3).toSet ();
104- var inheritedMethodElements = _inheritedElements
105+ var inheritedMethodElements = element.inheritedMembers.values
105106 .whereType <MethodElement2 >()
106- .where ((e) =>
107- ! e.isOperator &&
108- e is ! PropertyAccessorElement2 &&
109- ! methodNames.contains (e.name3))
110- .toSet ();
107+ .where ((e) => ! e.isOperator)
108+ .where ((e) => ! methodNames.contains (e.name3));
111109
112110 return [
113111 for (var e in inheritedMethodElements)
114112 getModelFor (e, library, enclosingContainer: this ) as Method ,
115113 ];
116114 }
117115
116+ @visibleForTesting
118117 List <Operator > get inheritedOperators {
119118 var operatorNames =
120119 declaredOperators.map ((o) => o.element.lookupName).toSet ();
121- var inheritedOperatorElements = _inheritedElements
120+ var inheritedOperatorElements = element.inheritedMembers.values
122121 .whereType <MethodElement2 >()
123- .where ((e) => e.isOperator && ! operatorNames. contains (e.lookupName) )
124- .toSet ( );
122+ .where ((e) => e.isOperator)
123+ .where ((e) => ! operatorNames. contains (e.name3) );
125124
126125 return [
127126 for (var e in inheritedOperatorElements)
@@ -132,74 +131,10 @@ abstract class InheritingContainer extends Container {
132131 late final DefinedElementType modelType =
133132 getTypeFor (element.thisType, library) as DefinedElementType ;
134133
135- /// A list of the inherited executable elements, one element per inherited
136- /// `Name` .
137- ///
138- /// In this list, elements that are "closer" in the inheritance chain to
139- /// _this_ element are preferred over elements that are further away. In the
140- /// case of ties, concrete inherited elements are prefered to non-concrete
141- /// ones.
142- late final List <ExecutableElement2 > _inheritedElements = () {
143- if (element case ClassElement2 classElement
144- when classElement.isDartCoreObject) {
145- return const < ExecutableElement2 > [];
146- }
147-
148- // The mapping of all of the inherited element names to their _concrete_
149- // implementation element.
150- var concreteInheritanceMap =
151- packageGraph.inheritanceManager.getInheritedConcreteMap (element);
152- // The mapping of all inherited element names to the nearest inherited
153- // element that they resolve to.
154- var inheritanceMap =
155- packageGraph.inheritanceManager.getInheritedMap (element);
156-
157- var inheritanceChainElements =
158- inheritanceChain.map ((c) => c.element).toList (growable: false );
159-
160- // A combined map of names to inherited _concrete_ Elements, and other
161- // inherited Elements.
162- var combinedMap = {
163- for (var MapEntry (: key, : value) in concreteInheritanceMap.entries)
164- key.name: value,
165- };
166- for (var MapEntry (key: name, value: inheritedElement)
167- in inheritanceMap.entries) {
168- var combinedMapElement = combinedMap[name.name];
169- if (combinedMapElement == null ) {
170- combinedMap[name.name] = inheritedElement;
171- continue ;
172- }
173-
174- // Elements in the inheritance chain starting from `this.element` up to,
175- // but not including, `Object`.
176- var enclosingElement =
177- inheritedElement.enclosingElement2 as InterfaceElement2 ;
178- assert (inheritanceChainElements.contains (enclosingElement) ||
179- enclosingElement.isDartCoreObject);
180-
181- // If the concrete element from `getInheritedConcreteMap2` is farther in
182- // the inheritance chain from this class than the (non-concrete) one
183- // provided by `getInheritedMap2`, prefer the latter. This correctly
184- // accounts for intermediate abstract classes that have method/field
185- // implementations.
186- var enclosingElementFromCombined =
187- combinedMapElement.enclosingElement2 as InterfaceElement2 ;
188- if (inheritanceChainElements.indexOf (enclosingElementFromCombined) <
189- inheritanceChainElements.indexOf (enclosingElement)) {
190- combinedMap[name.name] = inheritedElement;
191- }
192- }
193-
194- // Finally, return all of the elements ultimately collected in the combined
195- // map.
196- return combinedMap.values.toList (growable: false );
197- }();
198-
199134 /// All fields defined on this container, _including inherited fields_.
200- late List <Field > allFields = () {
135+ late final List <Field > _allFields = () {
201136 var inheritedAccessorElements = {
202- ..._inheritedElements .whereType <PropertyAccessorElement2 >()
137+ ...element.inheritedMembers.values .whereType <PropertyAccessorElement2 >()
203138 };
204139
205140 // This structure keeps track of inherited accessors, allowing lookup
@@ -285,17 +220,15 @@ abstract class InheritingContainer extends Container {
285220 List <ModelElement > get allModelElements => _allModelElements;
286221
287222 @override
288- Iterable <Field > get constantFields => allFields .where ((f) => f.isConst);
223+ Iterable <Field > get constantFields => _allFields .where ((f) => f.isConst);
289224
290225 @override
291- Iterable <Field > get declaredFields => allFields .where ((f) => ! f.isInherited);
226+ Iterable <Field > get declaredFields => _allFields .where ((f) => ! f.isInherited);
292227
293228 /// The [InheritingContainer] with the library in which [element] is defined.
294229 InheritingContainer get definingContainer =>
295230 getModelFor (element, library) as InheritingContainer ;
296231
297- @override
298-
299232 @override
300233 InterfaceElement2 get element;
301234
@@ -333,10 +266,10 @@ abstract class InheritingContainer extends Container {
333266 List <InheritingContainer > get inheritanceChain;
334267
335268 @visibleForTesting
336- Iterable <Field > get inheritedFields => allFields .where ((f) => f.isInherited);
269+ Iterable <Field > get inheritedFields => _allFields .where ((f) => f.isInherited);
337270
338271 @override
339- Iterable <Field > get instanceFields => allFields .where ((f) => ! f.isStatic);
272+ Iterable <Field > get instanceFields => _allFields .where ((f) => ! f.isStatic);
340273
341274 @override
342275 late final List <Field > availableInstanceFieldsSorted = [
@@ -371,8 +304,8 @@ abstract class InheritingContainer extends Container {
371304 List <Method > get _extensionInstanceMethods => [
372305 for (var extension in potentiallyApplicableExtensionsSorted)
373306 for (var method in extension .instanceMethods)
374- getModelFor (method.element, library,
375- enclosingContainer : extension ) as Method ,
307+ getModelFor (method.element, library, enclosingContainer : extension )
308+ as Method ,
376309 ];
377310
378311 @override
@@ -677,11 +610,6 @@ mixin MixedInTypes on InheritingContainer {
677610 mixedInTypes.wherePublic;
678611}
679612
680- extension on InterfaceElement2 {
681- bool get isDartCoreObject =>
682- name3 == 'Object' && library2.name3 == 'dart.core' ;
683- }
684-
685613extension DefinedElementTypeIterableExtension on Iterable <DefinedElementType > {
686614 /// The [ModelElement] for each element.
687615 List <InheritingContainer > get modelElements =>
0 commit comments