Skip to content

Commit

Permalink
Add InterfaceElementImpl, move many methods into it.
Browse files Browse the repository at this point in the history
Change-Id: I7f77e318586b2c05874b3a0d25d2d940869b6a0d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312240
Commit-Queue: Konstantin Shcheglov <[email protected]>
Reviewed-by: Samuel Rawlins <[email protected]>
  • Loading branch information
scheglov authored and Commit Queue committed Jul 4, 2023
1 parent d4de535 commit 37003ee
Show file tree
Hide file tree
Showing 10 changed files with 1,597 additions and 1,698 deletions.
3,254 changes: 1,577 additions & 1,677 deletions pkg/analyzer/lib/src/dart/element/element.dart

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions pkg/analyzer/lib/src/dart/element/type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer/lib/src/generated/element_type_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions pkg/analyzer/lib/src/summary2/bundle_reader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -668,7 +668,7 @@ class LibraryReader {

List<ConstructorElementImpl> _readConstructors(
CompilationUnitElementImpl unitElement,
AbstractClassElementImpl classElement,
InterfaceElementImpl classElement,
Reference classReference,
) {
var containerRef = classReference.getChild('@constructor');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -36,7 +36,7 @@ class ConstructorInitializerResolver {

void _constructor(
CompilationUnitElementImpl unitElement,
AbstractClassElementImpl classElement,
InterfaceElementImpl classElement,
ConstructorElementImpl element,
) {
if (element.isSynthetic) return;
Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer/lib/src/summary2/element_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
11 changes: 5 additions & 6 deletions pkg/analyzer/lib/src/summary2/types_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions pkg/analyzer/lib/src/task/strong_mode.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/nnbd_migration/lib/src/fix_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ class MigrationResolutionHooksImpl
}

@override
List<InterfaceType> getClassInterfaces(AbstractClassElementImpl element) {
List<InterfaceType> getClassInterfaces(InterfaceElementImpl element) {
return _wrapExceptions(
_fixBuilder.unit,
() => element.interfacesInternal,
Expand Down

0 comments on commit 37003ee

Please sign in to comment.