Skip to content

AST: Remove unused ArchetypeType::getAllNestedTypes() method #32674

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 1 addition & 19 deletions include/swift/AST/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -5571,25 +5571,7 @@ class ArchetypeType : public SubstitutableType,
/// find a particular nested type by name, directly, or look at the
/// protocols to which this archetype conforms.
ArrayRef<std::pair<Identifier, Type>>
getKnownNestedTypes(bool resolveTypes = true) const {
return getAllNestedTypes(/*resolveTypes=*/false);
}

/// Retrieve the nested types of this archetype.
///
/// \param resolveTypes Whether to eagerly resolve the nested types
/// (defaults to \c true). Otherwise, the nested types might be
/// null.
///
/// FIXME: This operation should go away, because it breaks recursive
/// protocol constraints.
ArrayRef<std::pair<Identifier, Type>>
getAllNestedTypes(bool resolveTypes = true) const;

/// Set the nested types to a copy of the given array of
/// archetypes.
void setNestedTypes(ASTContext &Ctx,
ArrayRef<std::pair<Identifier, Type>> Nested);
getKnownNestedTypes() const;

/// Register a nested type with the given name.
void registerNestedType(Identifier name, Type nested);
Expand Down
25 changes: 6 additions & 19 deletions lib/AST/Type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3210,7 +3210,11 @@ void ArchetypeType::populateNestedTypes() const {

// Record the nested types.
auto mutableThis = const_cast<ArchetypeType *>(this);
mutableThis->setNestedTypes(mutableThis->getASTContext(), nestedTypes);

std::sort(nestedTypes.begin(), nestedTypes.end(), OrderArchetypeByName());
auto &Ctx = mutableThis->getASTContext();
mutableThis->NestedTypes = Ctx.AllocateCopy(nestedTypes);
mutableThis->Bits.ArchetypeType.ExpandedNestedTypes = true;
}

Type ArchetypeType::getNestedType(Identifier Name) const {
Expand Down Expand Up @@ -3250,28 +3254,11 @@ bool ArchetypeType::hasNestedType(Identifier Name) const {
}

ArrayRef<std::pair<Identifier, Type>>
ArchetypeType::getAllNestedTypes(bool resolveTypes) const {
ArchetypeType::getKnownNestedTypes() const {
populateNestedTypes();

if (resolveTypes) {
for (auto &nested : NestedTypes) {
if (!nested.second)
resolveNestedType(nested);
}
}

return NestedTypes;
}

void ArchetypeType::setNestedTypes(
ASTContext &Ctx,
ArrayRef<std::pair<Identifier, Type>> Nested) {
assert(!Bits.ArchetypeType.ExpandedNestedTypes && "Already expanded");
NestedTypes = Ctx.AllocateCopy(Nested);
std::sort(NestedTypes.begin(), NestedTypes.end(), OrderArchetypeByName());
Bits.ArchetypeType.ExpandedNestedTypes = true;
}

void ArchetypeType::registerNestedType(Identifier name, Type nested) {
populateNestedTypes();

Expand Down