Skip to content

Commit 1992579

Browse files
authored
Merge pull request swiftlang#32674 from slavapestov/remove-archetype-get-all-nested-types
AST: Remove unused ArchetypeType::getAllNestedTypes() method
2 parents 9defc0a + 7b89eae commit 1992579

File tree

2 files changed

+7
-38
lines changed

2 files changed

+7
-38
lines changed

include/swift/AST/Types.h

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5571,25 +5571,7 @@ class ArchetypeType : public SubstitutableType,
55715571
/// find a particular nested type by name, directly, or look at the
55725572
/// protocols to which this archetype conforms.
55735573
ArrayRef<std::pair<Identifier, Type>>
5574-
getKnownNestedTypes(bool resolveTypes = true) const {
5575-
return getAllNestedTypes(/*resolveTypes=*/false);
5576-
}
5577-
5578-
/// Retrieve the nested types of this archetype.
5579-
///
5580-
/// \param resolveTypes Whether to eagerly resolve the nested types
5581-
/// (defaults to \c true). Otherwise, the nested types might be
5582-
/// null.
5583-
///
5584-
/// FIXME: This operation should go away, because it breaks recursive
5585-
/// protocol constraints.
5586-
ArrayRef<std::pair<Identifier, Type>>
5587-
getAllNestedTypes(bool resolveTypes = true) const;
5588-
5589-
/// Set the nested types to a copy of the given array of
5590-
/// archetypes.
5591-
void setNestedTypes(ASTContext &Ctx,
5592-
ArrayRef<std::pair<Identifier, Type>> Nested);
5574+
getKnownNestedTypes() const;
55935575

55945576
/// Register a nested type with the given name.
55955577
void registerNestedType(Identifier name, Type nested);

lib/AST/Type.cpp

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3210,7 +3210,11 @@ void ArchetypeType::populateNestedTypes() const {
32103210

32113211
// Record the nested types.
32123212
auto mutableThis = const_cast<ArchetypeType *>(this);
3213-
mutableThis->setNestedTypes(mutableThis->getASTContext(), nestedTypes);
3213+
3214+
std::sort(nestedTypes.begin(), nestedTypes.end(), OrderArchetypeByName());
3215+
auto &Ctx = mutableThis->getASTContext();
3216+
mutableThis->NestedTypes = Ctx.AllocateCopy(nestedTypes);
3217+
mutableThis->Bits.ArchetypeType.ExpandedNestedTypes = true;
32143218
}
32153219

32163220
Type ArchetypeType::getNestedType(Identifier Name) const {
@@ -3250,28 +3254,11 @@ bool ArchetypeType::hasNestedType(Identifier Name) const {
32503254
}
32513255

32523256
ArrayRef<std::pair<Identifier, Type>>
3253-
ArchetypeType::getAllNestedTypes(bool resolveTypes) const {
3257+
ArchetypeType::getKnownNestedTypes() const {
32543258
populateNestedTypes();
3255-
3256-
if (resolveTypes) {
3257-
for (auto &nested : NestedTypes) {
3258-
if (!nested.second)
3259-
resolveNestedType(nested);
3260-
}
3261-
}
3262-
32633259
return NestedTypes;
32643260
}
32653261

3266-
void ArchetypeType::setNestedTypes(
3267-
ASTContext &Ctx,
3268-
ArrayRef<std::pair<Identifier, Type>> Nested) {
3269-
assert(!Bits.ArchetypeType.ExpandedNestedTypes && "Already expanded");
3270-
NestedTypes = Ctx.AllocateCopy(Nested);
3271-
std::sort(NestedTypes.begin(), NestedTypes.end(), OrderArchetypeByName());
3272-
Bits.ArchetypeType.ExpandedNestedTypes = true;
3273-
}
3274-
32753262
void ArchetypeType::registerNestedType(Identifier name, Type nested) {
32763263
populateNestedTypes();
32773264

0 commit comments

Comments
 (0)