Skip to content

Commit 8194587

Browse files
committed
[GSB] Move several accessor functions off of PotentialArchetype.
These properties should be queried on the equivalence class itself.
1 parent 929c642 commit 8194587

File tree

2 files changed

+10
-44
lines changed

2 files changed

+10
-44
lines changed

include/swift/AST/GenericSignatureBuilder.h

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1593,42 +1593,13 @@ class GenericSignatureBuilder::PotentialArchetype {
15931593
return identifier.assocTypeOrConcrete;
15941594
}
15951595

1596-
/// Retrieve the set of protocols to which this potential archetype
1597-
/// conforms.
1598-
SmallVector<ProtocolDecl *, 4> getConformsTo() const {
1599-
SmallVector<ProtocolDecl *, 4> result;
1600-
1601-
if (auto equiv = getEquivalenceClassIfPresent()) {
1602-
for (const auto &entry : equiv->conformsTo)
1603-
result.push_back(entry.first);
1604-
}
1605-
1606-
return result;
1607-
}
1608-
16091596
/// Add a conformance to this potential archetype.
16101597
///
16111598
/// \returns true if the conformance was new, false if it already existed.
16121599
bool addConformance(ProtocolDecl *proto,
16131600
const RequirementSource *source,
16141601
GenericSignatureBuilder &builder);
16151602

1616-
/// Retrieve the superclass of this archetype.
1617-
Type getSuperclass() const {
1618-
if (auto equiv = getEquivalenceClassIfPresent())
1619-
return equiv->superclass;
1620-
1621-
return nullptr;
1622-
}
1623-
1624-
/// Retrieve the layout constraint of this archetype.
1625-
LayoutConstraint getLayout() const {
1626-
if (auto equivClass = getEquivalenceClassIfPresent())
1627-
return equivClass->layout;
1628-
1629-
return LayoutConstraint();
1630-
}
1631-
16321603
/// Retrieve the set of nested types.
16331604
const llvm::MapVector<Identifier, StoredNestedType> &getNestedTypes() const {
16341605
return NestedTypes;
@@ -1741,14 +1712,6 @@ class GenericSignatureBuilder::PotentialArchetype {
17411712
return false;
17421713
}
17431714

1744-
/// Get the concrete type this potential archetype is constrained to.
1745-
Type getConcreteType() const {
1746-
if (auto equivClass = getEquivalenceClassIfPresent())
1747-
return equivClass->concreteType;
1748-
1749-
return Type();
1750-
}
1751-
17521715
LLVM_ATTRIBUTE_DEPRECATED(
17531716
void dump() const,
17541717
"only for use within the debugger");

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2106,7 +2106,8 @@ static void addConditionalRequirements(GenericSignatureBuilder &builder,
21062106
const RequirementSource *
21072107
GenericSignatureBuilder::resolveConcreteConformance(PotentialArchetype *pa,
21082108
ProtocolDecl *proto) {
2109-
auto concrete = pa->getConcreteType();
2109+
auto equivClass = pa->getEquivalenceClassIfPresent();
2110+
auto concrete = equivClass ? equivClass->concreteType : Type();
21102111
if (!concrete) return nullptr;
21112112

21122113
// Conformance to this protocol is redundant; update the requirement source
@@ -2149,7 +2150,8 @@ const RequirementSource *GenericSignatureBuilder::resolveSuperConformance(
21492150
PotentialArchetype *pa,
21502151
ProtocolDecl *proto) {
21512152
// Get the superclass constraint.
2152-
Type superclass = pa->getSuperclass();
2153+
auto equivClass = pa->getEquivalenceClassIfPresent();
2154+
Type superclass = equivClass ? equivClass->superclass : nullptr;
21532155
if (!superclass) return nullptr;
21542156

21552157
// Lookup the conformance of the superclass to this protocol.
@@ -2710,7 +2712,7 @@ PotentialArchetype *PotentialArchetype::updateNestedTypeForConformance(
27102712
type = type.subst(subMap, SubstFlags::UseErrorType);
27112713
} else {
27122714
// Substitute in the superclass type.
2713-
auto superclass = getSuperclass();
2715+
auto superclass = getEquivalenceClassIfPresent()->superclass;
27142716
auto superclassDecl = superclass->getClassOrBoundGenericClass();
27152717
type = superclass->getTypeOfMember(
27162718
superclassDecl->getParentModule(), concreteDecl,
@@ -3580,7 +3582,8 @@ void GenericSignatureBuilder::updateSuperclass(
35803582
// Local function to handle the update of superclass conformances
35813583
// when the superclass constraint changes.
35823584
auto updateSuperclassConformances = [&] {
3583-
for (auto proto : T->getConformsTo()) {
3585+
for (const auto &conforms : equivClass->conformsTo) {
3586+
auto proto = conforms.first;
35843587
if (auto superSource = resolveSuperConformance(T, proto)) {
35853588
for (auto assocType : proto->getAssociatedTypeMembers()) {
35863589

@@ -4029,8 +4032,8 @@ ConstraintResult GenericSignatureBuilder::addSameTypeRequirementToConcrete(
40294032

40304033
// Make sure the concrete type fulfills the conformance requirements of
40314034
// this equivalence class.
4032-
for (auto protocol : rep->getConformsTo()) {
4033-
if (!resolveConcreteConformance(rep, protocol))
4035+
for (const auto &conforms : equivClass->conformsTo) {
4036+
if (!resolveConcreteConformance(rep, conforms.first))
40344037
return ConstraintResult::Conflicting;
40354038
}
40364039

@@ -6185,7 +6188,7 @@ void GenericSignatureBuilder::enumerateRequirements(llvm::function_ref<
61856188
if (knownAnchor != equivClass->derivedSameTypeComponents.end()) {
61866189
// If this equivalence class is bound to a concrete type, equate the
61876190
// anchor with a concrete type.
6188-
if (Type concreteType = rep->getConcreteType()) {
6191+
if (Type concreteType = equivClass->concreteType) {
61896192
// If the parent of this anchor is also a concrete type, don't
61906193
// create a requirement.
61916194
if (!archetype->isGenericParam() &&

0 commit comments

Comments
 (0)