Skip to content

Commit e59cdc8

Browse files
committed
AST: Remove TypeBase::getDirectlyReferencedTypeDecl()
1 parent 65088cc commit e59cdc8

File tree

3 files changed

+2
-39
lines changed

3 files changed

+2
-39
lines changed

include/swift/AST/Types.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -946,9 +946,6 @@ class alignas(1 << TypeAlignInBits) TypeBase {
946946
/// static conformance associated with the conforming type.
947947
bool hasDependentProtocolConformances();
948948

949-
/// Retrieve the type declaration directly referenced by this type, if any.
950-
TypeDecl *getDirectlyReferencedTypeDecl() const;
951-
952949
private:
953950
// Make vanilla new/delete illegal for Types.
954951
void *operator new(size_t Bytes) throw() = delete;

lib/AST/Type.cpp

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -955,38 +955,6 @@ Type TypeBase::getRValueInstanceType() {
955955
return type->getInOutObjectType();
956956
}
957957

958-
TypeDecl *TypeBase::getDirectlyReferencedTypeDecl() const {
959-
if (auto module = dyn_cast<ModuleType>(this))
960-
return module->getModule();
961-
962-
if (auto nominal = dyn_cast<NominalType>(this))
963-
return nominal->getDecl();
964-
965-
if (auto bound = dyn_cast<BoundGenericType>(this))
966-
return bound->getDecl();
967-
968-
if (auto unbound = dyn_cast<UnboundGenericType>(this))
969-
return unbound->getDecl();
970-
971-
if (auto alias = dyn_cast<NameAliasType>(this))
972-
return alias->getDecl();
973-
974-
if (auto gp = dyn_cast<GenericTypeParamType>(this))
975-
return gp->getDecl();
976-
977-
if (auto depMem = dyn_cast<DependentMemberType>(this))
978-
return depMem->getAssocType();
979-
980-
if (auto archetype = dyn_cast<ArchetypeType>(this)) {
981-
if (auto assoc = archetype->getAssocType())
982-
return assoc;
983-
984-
return nullptr;
985-
}
986-
987-
return nullptr;
988-
}
989-
990958
/// \brief Collect the protocols in the existential type T into the given
991959
/// vector.
992960
static void addProtocols(Type T, SmallVectorImpl<ProtocolDecl *> &Protocols) {

lib/Index/Index.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -575,8 +575,7 @@ bool IndexSwiftASTWalker::passRelatedType(const TypeLoc &Ty) {
575575
}
576576

577577
if (Ty.getType()) {
578-
if (auto nominal = dyn_cast_or_null<NominalTypeDecl>(
579-
Ty.getType()->getDirectlyReferencedTypeDecl()))
578+
if (auto nominal = Ty.getType()->getAnyNominal())
580579
if (!passRelated(nominal, Ty.getLoc()))
581580
return false;
582581
}
@@ -644,8 +643,7 @@ bool IndexSwiftASTWalker::reportPseudoAccessor(AbstractStorageDecl *D,
644643
NominalTypeDecl *
645644
IndexSwiftASTWalker::getTypeLocAsNominalTypeDecl(const TypeLoc &Ty) {
646645
if (Type T = Ty.getType())
647-
return dyn_cast_or_null<NominalTypeDecl>(
648-
T->getDirectlyReferencedTypeDecl());
646+
return T->getAnyNominal();
649647
if (IdentTypeRepr *T = dyn_cast_or_null<IdentTypeRepr>(Ty.getTypeRepr())) {
650648
auto Comp = T->getComponentRange().back();
651649
if (auto NTD = dyn_cast_or_null<NominalTypeDecl>(Comp->getBoundDecl()))

0 commit comments

Comments
 (0)