mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 00:09:49 +00:00
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:
parent
d4de535a3a
commit
37003ee3be
File diff suppressed because it is too large
Load diff
|
@ -789,7 +789,7 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recoveryStatic) {
|
if (recoveryStatic) {
|
||||||
final element = this.element as AbstractClassElementImpl;
|
final element = this.element as InterfaceElementImpl;
|
||||||
return element.lookupStaticGetter(name, library);
|
return element.lookupStaticGetter(name, library);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -828,7 +828,7 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recoveryStatic) {
|
if (recoveryStatic) {
|
||||||
final element = this.element as AbstractClassElementImpl;
|
final element = this.element as InterfaceElementImpl;
|
||||||
return element.lookupStaticMethod(name, library);
|
return element.lookupStaticMethod(name, library);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -867,7 +867,7 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recoveryStatic) {
|
if (recoveryStatic) {
|
||||||
final element = this.element as AbstractClassElementImpl;
|
final element = this.element as InterfaceElementImpl;
|
||||||
return element.lookupStaticSetter(name, library);
|
return element.lookupStaticSetter(name, library);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -258,7 +258,7 @@ class TypePropertyResolver {
|
||||||
_needsGetterError = _getterRequested == null;
|
_needsGetterError = _getterRequested == null;
|
||||||
|
|
||||||
if (_getterRequested == null && recoverWithStatic) {
|
if (_getterRequested == null && recoverWithStatic) {
|
||||||
var classElement = type.element as AbstractClassElementImpl;
|
var classElement = type.element as InterfaceElementImpl;
|
||||||
_getterRecovery ??=
|
_getterRecovery ??=
|
||||||
classElement.lookupStaticGetter(_name, _definingLibrary) ??
|
classElement.lookupStaticGetter(_name, _definingLibrary) ??
|
||||||
classElement.lookupStaticMethod(_name, _definingLibrary);
|
classElement.lookupStaticMethod(_name, _definingLibrary);
|
||||||
|
@ -271,7 +271,7 @@ class TypePropertyResolver {
|
||||||
_needsSetterError = _setterRequested == null;
|
_needsSetterError = _setterRequested == null;
|
||||||
|
|
||||||
if (_setterRequested == null && recoverWithStatic) {
|
if (_setterRequested == null && recoverWithStatic) {
|
||||||
var classElement = type.element as AbstractClassElementImpl;
|
var classElement = type.element as InterfaceElementImpl;
|
||||||
_setterRecovery ??=
|
_setterRecovery ??=
|
||||||
classElement.lookupStaticSetter(_name, _definingLibrary);
|
classElement.lookupStaticSetter(_name, _definingLibrary);
|
||||||
_needsSetterError = _setterRecovery == null;
|
_needsSetterError = _setterRecovery == null;
|
||||||
|
|
|
@ -32,7 +32,7 @@ class ElementTypeProvider {
|
||||||
void freshTypeParameterCreated(TypeParameterElement newTypeParameter,
|
void freshTypeParameterCreated(TypeParameterElement newTypeParameter,
|
||||||
TypeParameterElement oldTypeParameter) {}
|
TypeParameterElement oldTypeParameter) {}
|
||||||
|
|
||||||
List<InterfaceType> getClassInterfaces(AbstractClassElementImpl element) =>
|
List<InterfaceType> getClassInterfaces(InterfaceElementImpl element) =>
|
||||||
element.interfacesInternal;
|
element.interfacesInternal;
|
||||||
|
|
||||||
/// Queries the parameters of an executable element's signature.
|
/// Queries the parameters of an executable element's signature.
|
||||||
|
|
|
@ -101,8 +101,8 @@ class ClassElementLinkedData extends ElementLinkedData<ClassElementImpl> {
|
||||||
/// as well access them through their [Reference]s. For a class declaration
|
/// as well access them through their [Reference]s. For a class declaration
|
||||||
/// this means reading them, for a named mixin application this means
|
/// this means reading them, for a named mixin application this means
|
||||||
/// computing constructors.
|
/// computing constructors.
|
||||||
void readMembers(ClassOrMixinElementImpl element) {
|
void readMembers(ClassElementImpl element) {
|
||||||
if (element is ClassElementImpl && element.isMixinApplication) {
|
if (element.isMixinApplication) {
|
||||||
element.constructors;
|
element.constructors;
|
||||||
} else {
|
} else {
|
||||||
_readMembers?.call();
|
_readMembers?.call();
|
||||||
|
@ -668,7 +668,7 @@ class LibraryReader {
|
||||||
|
|
||||||
List<ConstructorElementImpl> _readConstructors(
|
List<ConstructorElementImpl> _readConstructors(
|
||||||
CompilationUnitElementImpl unitElement,
|
CompilationUnitElementImpl unitElement,
|
||||||
AbstractClassElementImpl classElement,
|
InterfaceElementImpl classElement,
|
||||||
Reference classReference,
|
Reference classReference,
|
||||||
) {
|
) {
|
||||||
var containerRef = classReference.getChild('@constructor');
|
var containerRef = classReference.getChild('@constructor');
|
||||||
|
|
|
@ -17,7 +17,7 @@ class ConstructorInitializerResolver {
|
||||||
|
|
||||||
void resolve() {
|
void resolve() {
|
||||||
for (var unitElement in _libraryElement.units) {
|
for (var unitElement in _libraryElement.units) {
|
||||||
var interfaceElements = [
|
var interfaceElements = <InterfaceElementImpl>[
|
||||||
...unitElement.classes,
|
...unitElement.classes,
|
||||||
...unitElement.enums,
|
...unitElement.enums,
|
||||||
...unitElement.mixins,
|
...unitElement.mixins,
|
||||||
|
@ -36,7 +36,7 @@ class ConstructorInitializerResolver {
|
||||||
|
|
||||||
void _constructor(
|
void _constructor(
|
||||||
CompilationUnitElementImpl unitElement,
|
CompilationUnitElementImpl unitElement,
|
||||||
AbstractClassElementImpl classElement,
|
InterfaceElementImpl classElement,
|
||||||
ConstructorElementImpl element,
|
ConstructorElementImpl element,
|
||||||
) {
|
) {
|
||||||
if (element.isSynthetic) return;
|
if (element.isSynthetic) return;
|
||||||
|
|
|
@ -1241,7 +1241,7 @@ class ElementBuilder extends ThrowingAstVisitor<void> {
|
||||||
node?.accept(this);
|
node?.accept(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _resolveConstructorFieldFormals(AbstractClassElementImpl element) {
|
void _resolveConstructorFieldFormals(InterfaceElementImpl element) {
|
||||||
for (var constructor in element.constructors) {
|
for (var constructor in element.constructors) {
|
||||||
for (var parameter in constructor.parameters) {
|
for (var parameter in constructor.parameters) {
|
||||||
if (parameter is FieldFormalParameterElementImpl) {
|
if (parameter is FieldFormalParameterElementImpl) {
|
||||||
|
|
|
@ -362,14 +362,14 @@ class TypesBuilder {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static InterfaceType _objectType(AbstractClassElementImpl element) {
|
static InterfaceType _objectType(InterfaceElementImpl element) {
|
||||||
return element.library.typeProvider.objectType;
|
return element.library.typeProvider.objectType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Performs mixins inference in a [ClassDeclaration].
|
/// Performs mixins inference in a [ClassDeclaration].
|
||||||
class _MixinInference {
|
class _MixinInference {
|
||||||
final AbstractClassElementImpl element;
|
final InterfaceElementImpl element;
|
||||||
final TypeSystemImpl typeSystem;
|
final TypeSystemImpl typeSystem;
|
||||||
final FeatureSet featureSet;
|
final FeatureSet featureSet;
|
||||||
final InterfaceType classType;
|
final InterfaceType classType;
|
||||||
|
@ -534,15 +534,14 @@ class _MixinsInference {
|
||||||
/// we are inferring the [element] now, i.e. there is a loop.
|
/// 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.
|
/// 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;
|
element.mixinInferenceCallback = null;
|
||||||
return <InterfaceType>[];
|
return <InterfaceType>[];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This method is invoked when mixins are asked from the [element], and
|
/// 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.
|
/// we are not inferring the [element] now, i.e. there is no loop.
|
||||||
List<InterfaceType>? _callbackWhenRecursion(
|
List<InterfaceType>? _callbackWhenRecursion(InterfaceElementImpl element) {
|
||||||
AbstractClassElementImpl element) {
|
|
||||||
var node = _linker.getLinkingNode(element);
|
var node = _linker.getLinkingNode(element);
|
||||||
if (node != null) {
|
if (node != null) {
|
||||||
_inferDeclaration(node);
|
_inferDeclaration(node);
|
||||||
|
@ -551,7 +550,7 @@ class _MixinsInference {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _infer(AbstractClassElementImpl element, WithClause? withClause) {
|
void _infer(InterfaceElementImpl element, WithClause? withClause) {
|
||||||
if (withClause != null) {
|
if (withClause != null) {
|
||||||
element.mixinInferenceCallback = _callbackWhenLoop;
|
element.mixinInferenceCallback = _callbackWhenLoop;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -303,7 +303,7 @@ class InstanceMemberInferrer {
|
||||||
/// [classElement].
|
/// [classElement].
|
||||||
void _inferClass(InterfaceElement classElement) {
|
void _inferClass(InterfaceElement classElement) {
|
||||||
_setInducedModifier(classElement);
|
_setInducedModifier(classElement);
|
||||||
if (classElement is AbstractClassElementImpl) {
|
if (classElement is InterfaceElementImpl) {
|
||||||
if (classElement.hasBeenInferred) {
|
if (classElement.hasBeenInferred) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -338,7 +338,7 @@ class InstanceMemberInferrer {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
for (var method in classElement.methods) {
|
for (var method in classElement.methods) {
|
||||||
_inferExecutable(method as MethodElementImpl);
|
_inferExecutable(method);
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// Infer initializing formal parameter types. This must happen after
|
// Infer initializing formal parameter types. This must happen after
|
||||||
|
|
|
@ -374,7 +374,7 @@ class MigrationResolutionHooksImpl
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<InterfaceType> getClassInterfaces(AbstractClassElementImpl element) {
|
List<InterfaceType> getClassInterfaces(InterfaceElementImpl element) {
|
||||||
return _wrapExceptions(
|
return _wrapExceptions(
|
||||||
_fixBuilder.unit,
|
_fixBuilder.unit,
|
||||||
() => element.interfacesInternal,
|
() => element.interfacesInternal,
|
||||||
|
|
Loading…
Reference in a new issue