Add InterfaceElementImpl, move many methods into it.

Change-Id: I7f77e318586b2c05874b3a0d25d2d940869b6a0d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312240
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
This commit is contained in:
Konstantin Shcheglov 2023-07-04 01:41:38 +00:00 committed by Commit Queue
parent d4de535a3a
commit 37003ee3be
10 changed files with 551 additions and 652 deletions

File diff suppressed because it is too large Load diff

View file

@ -789,7 +789,7 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
}
if (recoveryStatic) {
final element = this.element as AbstractClassElementImpl;
final element = this.element as InterfaceElementImpl;
return element.lookupStaticGetter(name, library);
}
@ -828,7 +828,7 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
}
if (recoveryStatic) {
final element = this.element as AbstractClassElementImpl;
final element = this.element as InterfaceElementImpl;
return element.lookupStaticMethod(name, library);
}
@ -867,7 +867,7 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
}
if (recoveryStatic) {
final element = this.element as AbstractClassElementImpl;
final element = this.element as InterfaceElementImpl;
return element.lookupStaticSetter(name, library);
}

View file

@ -258,7 +258,7 @@ class TypePropertyResolver {
_needsGetterError = _getterRequested == null;
if (_getterRequested == null && recoverWithStatic) {
var classElement = type.element as AbstractClassElementImpl;
var classElement = type.element as InterfaceElementImpl;
_getterRecovery ??=
classElement.lookupStaticGetter(_name, _definingLibrary) ??
classElement.lookupStaticMethod(_name, _definingLibrary);
@ -271,7 +271,7 @@ class TypePropertyResolver {
_needsSetterError = _setterRequested == null;
if (_setterRequested == null && recoverWithStatic) {
var classElement = type.element as AbstractClassElementImpl;
var classElement = type.element as InterfaceElementImpl;
_setterRecovery ??=
classElement.lookupStaticSetter(_name, _definingLibrary);
_needsSetterError = _setterRecovery == null;

View file

@ -32,7 +32,7 @@ class ElementTypeProvider {
void freshTypeParameterCreated(TypeParameterElement newTypeParameter,
TypeParameterElement oldTypeParameter) {}
List<InterfaceType> getClassInterfaces(AbstractClassElementImpl element) =>
List<InterfaceType> getClassInterfaces(InterfaceElementImpl element) =>
element.interfacesInternal;
/// Queries the parameters of an executable element's signature.

View file

@ -101,8 +101,8 @@ class ClassElementLinkedData extends ElementLinkedData<ClassElementImpl> {
/// as well access them through their [Reference]s. For a class declaration
/// this means reading them, for a named mixin application this means
/// computing constructors.
void readMembers(ClassOrMixinElementImpl element) {
if (element is ClassElementImpl && element.isMixinApplication) {
void readMembers(ClassElementImpl element) {
if (element.isMixinApplication) {
element.constructors;
} else {
_readMembers?.call();
@ -668,7 +668,7 @@ class LibraryReader {
List<ConstructorElementImpl> _readConstructors(
CompilationUnitElementImpl unitElement,
AbstractClassElementImpl classElement,
InterfaceElementImpl classElement,
Reference classReference,
) {
var containerRef = classReference.getChild('@constructor');

View file

@ -17,7 +17,7 @@ class ConstructorInitializerResolver {
void resolve() {
for (var unitElement in _libraryElement.units) {
var interfaceElements = [
var interfaceElements = <InterfaceElementImpl>[
...unitElement.classes,
...unitElement.enums,
...unitElement.mixins,
@ -36,7 +36,7 @@ class ConstructorInitializerResolver {
void _constructor(
CompilationUnitElementImpl unitElement,
AbstractClassElementImpl classElement,
InterfaceElementImpl classElement,
ConstructorElementImpl element,
) {
if (element.isSynthetic) return;

View file

@ -1241,7 +1241,7 @@ class ElementBuilder extends ThrowingAstVisitor<void> {
node?.accept(this);
}
void _resolveConstructorFieldFormals(AbstractClassElementImpl element) {
void _resolveConstructorFieldFormals(InterfaceElementImpl element) {
for (var constructor in element.constructors) {
for (var parameter in constructor.parameters) {
if (parameter is FieldFormalParameterElementImpl) {

View file

@ -362,14 +362,14 @@ class TypesBuilder {
);
}
static InterfaceType _objectType(AbstractClassElementImpl element) {
static InterfaceType _objectType(InterfaceElementImpl element) {
return element.library.typeProvider.objectType;
}
}
/// Performs mixins inference in a [ClassDeclaration].
class _MixinInference {
final AbstractClassElementImpl element;
final InterfaceElementImpl element;
final TypeSystemImpl typeSystem;
final FeatureSet featureSet;
final InterfaceType classType;
@ -534,15 +534,14 @@ class _MixinsInference {
/// we are inferring the [element] now, i.e. there is a loop.
///
/// This is an error. So, we return the empty list, and break the loop.
List<InterfaceType> _callbackWhenLoop(AbstractClassElementImpl element) {
List<InterfaceType> _callbackWhenLoop(InterfaceElementImpl element) {
element.mixinInferenceCallback = null;
return <InterfaceType>[];
}
/// This method is invoked when mixins are asked from the [element], and
/// we are not inferring the [element] now, i.e. there is no loop.
List<InterfaceType>? _callbackWhenRecursion(
AbstractClassElementImpl element) {
List<InterfaceType>? _callbackWhenRecursion(InterfaceElementImpl element) {
var node = _linker.getLinkingNode(element);
if (node != null) {
_inferDeclaration(node);
@ -551,7 +550,7 @@ class _MixinsInference {
return null;
}
void _infer(AbstractClassElementImpl element, WithClause? withClause) {
void _infer(InterfaceElementImpl element, WithClause? withClause) {
if (withClause != null) {
element.mixinInferenceCallback = _callbackWhenLoop;
try {

View file

@ -303,7 +303,7 @@ class InstanceMemberInferrer {
/// [classElement].
void _inferClass(InterfaceElement classElement) {
_setInducedModifier(classElement);
if (classElement is AbstractClassElementImpl) {
if (classElement is InterfaceElementImpl) {
if (classElement.hasBeenInferred) {
return;
}
@ -338,7 +338,7 @@ class InstanceMemberInferrer {
);
}
for (var method in classElement.methods) {
_inferExecutable(method as MethodElementImpl);
_inferExecutable(method);
}
//
// Infer initializing formal parameter types. This must happen after

View file

@ -374,7 +374,7 @@ class MigrationResolutionHooksImpl
}
@override
List<InterfaceType> getClassInterfaces(AbstractClassElementImpl element) {
List<InterfaceType> getClassInterfaces(InterfaceElementImpl element) {
return _wrapExceptions(
_fixBuilder.unit,
() => element.interfacesInternal,