Skip to content

Commit 2a90cd1

Browse files
committed
Eliminate and simplify some uses of NestedArchetypeType.
1 parent bd112ca commit 2a90cd1

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

lib/AST/Type.cpp

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3421,8 +3421,8 @@ static bool canSubstituteTypeInto(Type ty, const DeclContext *dc,
34213421
// The referenced type might be a different opaque result type.
34223422

34233423
// First, unwrap any nested associated types to get the root archetype.
3424-
while (auto nestedTy = ty->getAs<NestedArchetypeType>())
3425-
ty = nestedTy->getParent();
3424+
if (auto nestedTy = ty->getAs<NestedArchetypeType>())
3425+
ty = nestedTy->getRoot();
34263426

34273427
// If the root archetype is an opaque result type, check that its
34283428
// descriptor is accessible.
@@ -3786,31 +3786,19 @@ void ArchetypeType::registerNestedType(Identifier name, Type nested) {
37863786
found->second = nested;
37873787
}
37883788

3789-
static void collectFullName(const ArchetypeType *Archetype,
3790-
SmallVectorImpl<char> &Result) {
3791-
if (auto nested = dyn_cast<NestedArchetypeType>(Archetype)) {
3792-
collectFullName(nested->getParent(), Result);
3793-
Result.push_back('.');
3794-
}
3795-
Result.append(Archetype->getName().str().begin(),
3796-
Archetype->getName().str().end());
3797-
}
3798-
37993789
AssociatedTypeDecl *NestedArchetypeType::getAssocType() const {
38003790
return InterfaceType->castTo<DependentMemberType>()->getAssocType();
38013791
}
38023792

38033793
Identifier ArchetypeType::getName() const {
3804-
if (auto nested = dyn_cast<NestedArchetypeType>(this))
3805-
return nested->getAssocType()->getName();
38063794
assert(InterfaceType);
3795+
if (auto depMemTy = InterfaceType->getAs<DependentMemberType>())
3796+
return depMemTy->getName();
38073797
return InterfaceType->castTo<GenericTypeParamType>()->getName();
38083798
}
38093799

38103800
std::string ArchetypeType::getFullName() const {
3811-
llvm::SmallString<64> Result;
3812-
collectFullName(this, Result);
3813-
return Result.str().str();
3801+
return InterfaceType.getString();
38143802
}
38153803

38163804
void ProtocolCompositionType::Profile(llvm::FoldingSetNodeID &ID,

0 commit comments

Comments
 (0)