@@ -89,40 +89,6 @@ class InheritanceManager3 {
8989 /// self-referencing cycles.
9090 final Set <InterfaceFragmentImpl > _processingClasses = {};
9191
92- /// Combine [candidates] into a single signature in the [targetClass] .
93- ///
94- /// If such signature does not exist, return `null` , and if [conflicts] is
95- /// not `null` , add a new [Conflict] to it.
96- ExecutableElementOrMember ? combineSignatures ({
97- required InterfaceFragmentImpl targetClass,
98- required List <ExecutableElementOrMember > candidates,
99- required Name name,
100- List <Conflict >? conflicts,
101- }) {
102- // If just one candidate, it is always valid.
103- if (candidates.length == 1 ) {
104- return candidates[0 ];
105- }
106-
107- var targetLibrary = targetClass.library;
108- var typeSystem = targetLibrary.typeSystem;
109-
110- var validOverrides = _getValidOverrides (
111- candidates: candidates,
112- typeSystem: typeSystem,
113- );
114-
115- if (validOverrides.isEmpty) {
116- conflicts? .add (CandidatesConflict (name: name, candidates: candidates));
117- return null ;
118- }
119-
120- (_combinedSignatures[targetClass] ?? = {})[name] =
121- candidates.map ((e) => e.asElement2).toList ();
122-
123- return _topMerge (typeSystem, targetClass, validOverrides);
124- }
125-
12692 /// Combine types of [candidates] into a single most specific type.
12793 ///
12894 /// If such signature does not exist, return `null` , and if [conflicts] is
@@ -164,26 +130,12 @@ class InheritanceManager3 {
164130 );
165131 }
166132
167- /// Return the result of [getInherited2] with [type] substitution.
168- ExecutableElementOrMember ? getInherited (InterfaceType type, Name name) {
169- type as InterfaceTypeImpl ;
170- var rawElement = getInherited2 (type.element3.asElement, name);
171- if (rawElement == null ) {
172- return null ;
173- }
174-
175- return ExecutableMember .from2 (
176- rawElement,
177- Substitution .fromInterfaceType (type),
178- );
179- }
180-
181133 /// Return the most specific signature of the member with the given [name]
182134 /// that [element] inherits from the mixins, superclasses, or interfaces;
183135 /// or `null` if no member is inherited because the member is not declared
184136 /// at all, or because there is no the most specific signature.
185137 ///
186- /// This is equivalent to `getInheritedMap2(type )[name]` .
138+ /// This is equivalent to `getInheritedMap2(element )[name]` .
187139 ExecutableElementOrMember ? getInherited2 (
188140 InterfaceFragmentImpl element,
189141 Name name,
@@ -192,11 +144,20 @@ class InheritanceManager3 {
192144 }
193145
194146 /// Returns the result of [getInherited2] with [type] substitution.
195- // This is a replacement for `getInherited`.
196147 @experimental
197148 ExecutableElement ? getInherited3 (InterfaceType type, Name name) {
198- var element = getInherited (type, name);
199- return element? .asElement2;
149+ type as InterfaceTypeImpl ;
150+ var rawElement = getInherited2 (type.element3.asElement, name);
151+ if (rawElement == null ) {
152+ return null ;
153+ }
154+
155+ var element = ExecutableMember .from2 (
156+ rawElement,
157+ Substitution .fromInterfaceType (type),
158+ );
159+
160+ return element.asElement2;
200161 }
201162
202163 /// Returns the most specific signature of the member with the given [name]
@@ -224,26 +185,20 @@ class InheritanceManager3 {
224185 InterfaceElement element,
225186 ) {
226187 element as InterfaceElementImpl2 ; // TODO(scheglov): remove cast
227- var map = getInheritedConcreteMap2 (element.asElement);
228- return map.mapValue ((element) => element.asElement2);
229- }
188+ var fragment = element.asElement;
230189
231- /// Return signatures of all concrete members that the given [element] inherits
232- /// from the superclasses and mixins.
233- Map <Name , ExecutableElementOrMember > getInheritedConcreteMap2 (
234- InterfaceFragmentImpl element,
235- ) {
236- if (element is ExtensionTypeFragmentImpl ) {
190+ if (fragment is ExtensionTypeFragmentImpl ) {
237191 return const {};
238192 }
239193
240- var interface = getInterface (element);
241- if (interface .superImplemented.isNotEmpty) {
242- return interface .superImplemented.last;
243- } else {
244- assert (element.name2 == 'Object' );
194+ var interface = getInterface (fragment);
195+ if (interface .superImplemented.isEmpty) {
196+ assert (fragment.name2 == 'Object' );
245197 return const {};
246198 }
199+
200+ var map = interface .superImplemented.last;
201+ return map.mapValue ((e) => e.asElement2);
247202 }
248203
249204 /// Returns the mapping from names to most specific signatures of members
@@ -443,20 +398,6 @@ class InheritanceManager3 {
443398 return oldElement? .asElement2;
444399 }
445400
446- /// Returns all members of mixins, superclasses, and interfaces that a member
447- /// with the given [name] , defined in the [element] , would override.
448- ///
449- /// Returns `null` if no members would be overridden.
450- @experimental
451- List <ExecutableElement >? getOverridden (InterfaceElement element, Name name) {
452- element as InterfaceElementImpl2 ; // TODO(scheglov): remove cast
453- var elements = getOverridden2 (element.asElement, name);
454- if (elements == null ) {
455- return null ;
456- }
457- return elements.map ((fragment) => fragment.asElement2).toList ();
458- }
459-
460401 /// Return all members of mixins, superclasses, and interfaces that a member
461402 /// with the given [name] , defined in the [element] , would override; or `null`
462403 /// if no members would be overridden.
@@ -578,6 +519,40 @@ class InheritanceManager3 {
578519 }
579520 }
580521
522+ /// Combine [candidates] into a single signature in the [targetClass] .
523+ ///
524+ /// If such signature does not exist, return `null` , and if [conflicts] is
525+ /// not `null` , add a new [Conflict] to it.
526+ ExecutableElementOrMember ? _combineSignatures ({
527+ required InterfaceFragmentImpl targetClass,
528+ required List <ExecutableElementOrMember > candidates,
529+ required Name name,
530+ List <Conflict >? conflicts,
531+ }) {
532+ // If just one candidate, it is always valid.
533+ if (candidates.length == 1 ) {
534+ return candidates[0 ];
535+ }
536+
537+ var targetLibrary = targetClass.library;
538+ var typeSystem = targetLibrary.typeSystem;
539+
540+ var validOverrides = _getValidOverrides (
541+ candidates: candidates,
542+ typeSystem: typeSystem,
543+ );
544+
545+ if (validOverrides.isEmpty) {
546+ conflicts? .add (CandidatesConflict (name: name, candidates: candidates));
547+ return null ;
548+ }
549+
550+ (_combinedSignatures[targetClass] ?? = {})[name] =
551+ candidates.map ((e) => e.asElement2).toList ();
552+
553+ return _topMerge (typeSystem, targetClass, validOverrides);
554+ }
555+
581556 /// The given [namedCandidates] maps names to candidates from direct
582557 /// superinterfaces. Find the most specific signature, and put it into the
583558 /// [map] , if there is no one yet (from the class itself). If there is no
@@ -607,7 +582,7 @@ class InheritanceManager3 {
607582 continue ;
608583 }
609584
610- var combinedSignature = combineSignatures (
585+ var combinedSignature = _combineSignatures (
611586 targetClass: targetClass,
612587 candidates: candidates,
613588 name: name,
@@ -965,7 +940,7 @@ class InheritanceManager3 {
965940 continue ;
966941 }
967942
968- var combinedSignature = combineSignatures (
943+ var combinedSignature = _combineSignatures (
969944 targetClass: fragment,
970945 candidates: notPrecluded,
971946 name: name,
0 commit comments