AST: Introduce abstraction for extension/type decl inheritance clauses.

Wrap the `InheritedEntry` array available on both `ExtensionDecl` and
`TypeDecl` in a new `InheritedTypes` class. This class will provide shared
conveniences for working with inherited type clauses. NFC.
This commit is contained in:
Allan Shortlidge
2023-09-05 17:08:05 -07:00
parent 2c3c3c1933
commit 0dd8f4c492
33 changed files with 221 additions and 163 deletions

View File

@@ -974,8 +974,7 @@ private:
/// \param Loc The location of the reference, otherwise the location of the TypeLoc is used.
bool reportRelatedTypeRef(const TypeLoc &Ty, SymbolRoleSet Relations, Decl *Related,
bool isImplicit=false, SourceLoc Loc={});
bool reportInheritedTypeRefs(
ArrayRef<InheritedEntry> Inherited, Decl *Inheritee);
bool reportInheritedTypeRefs(InheritedTypes Inherited, Decl *Inheritee);
bool reportPseudoGetterDecl(VarDecl *D) {
return reportPseudoAccessor(D, AccessorKind::Get, /*IsRef=*/false,
@@ -1073,7 +1072,7 @@ private:
if (shouldIndex(VD, /*IsRef=*/false))
return true;
for (auto Inherit : D->getInherited())
for (auto Inherit : D->getInherited().getEntries())
if (auto T = Inherit.getType())
if (T->getAnyNominal() &&
shouldIndex(T->getAnyNominal(), /*IsRef=*/false))
@@ -1384,8 +1383,9 @@ bool IndexSwiftASTWalker::reportRelatedRef(ValueDecl *D, SourceLoc Loc, bool isI
return !Cancelled;
}
bool IndexSwiftASTWalker::reportInheritedTypeRefs(ArrayRef<InheritedEntry> Inherited, Decl *Inheritee) {
for (auto Base : Inherited) {
bool IndexSwiftASTWalker::reportInheritedTypeRefs(InheritedTypes Inherited,
Decl *Inheritee) {
for (auto Base : Inherited.getEntries()) {
if (!reportRelatedTypeRef(Base, (SymbolRoleSet) SymbolRole::RelationBaseOf, Inheritee))
return false;
}