Skip to content

Commit 97250c8

Browse files
authored
Merge pull request #12477 from DougGregor/gsb-lazy-resolve-equiv-classes
2 parents ab06b14 + 9314e48 commit 97250c8

File tree

2 files changed

+222
-107
lines changed

2 files changed

+222
-107
lines changed

include/swift/AST/GenericSignatureBuilder.h

Lines changed: 12 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ class GenericSignatureBuilder {
158158
std::vector<Constraint<LayoutConstraint>> layoutConstraints;
159159

160160
/// The members of the equivalence class.
161+
///
162+
/// This list of members is slightly ordered, in that the first
163+
/// element always has a depth no greater than the depth of any other
164+
/// member.
161165
TinyPtrVector<PotentialArchetype *> members;
162166

163167
/// Describes a component within the graph of same-type constraints within
@@ -203,6 +207,9 @@ class GenericSignatureBuilder {
203207
EquivalenceClass &operator=(const EquivalenceClass &) = delete;
204208
EquivalenceClass &operator=(EquivalenceClass &&) = delete;
205209

210+
/// Add a new member to this equivalence class.
211+
void addMember(PotentialArchetype *pa);
212+
206213
/// Record the conformance of this equivalence class to the given
207214
/// protocol as found via the given requirement source.
208215
///
@@ -758,6 +765,11 @@ class GenericSignatureBuilder {
758765
resolvePotentialArchetype(Type type,
759766
ArchetypeResolutionKind resolutionKind);
760767

768+
/// \brief Try to resolvew the equivalence class of the given type.
769+
ResolveResult maybeResolveEquivalenceClass(
770+
Type type,
771+
ArchetypeResolutionKind resolutionKind);
772+
761773
/// \brief Resolve the equivalence class for the given type parameter,
762774
/// which provides information about that type.
763775
///
@@ -1593,42 +1605,13 @@ class GenericSignatureBuilder::PotentialArchetype {
15931605
return identifier.assocTypeOrConcrete;
15941606
}
15951607

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-
16091608
/// Add a conformance to this potential archetype.
16101609
///
16111610
/// \returns true if the conformance was new, false if it already existed.
16121611
bool addConformance(ProtocolDecl *proto,
16131612
const RequirementSource *source,
16141613
GenericSignatureBuilder &builder);
16151614

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-
16321615
/// Retrieve the set of nested types.
16331616
const llvm::MapVector<Identifier, StoredNestedType> &getNestedTypes() const {
16341617
return NestedTypes;
@@ -1741,14 +1724,6 @@ class GenericSignatureBuilder::PotentialArchetype {
17411724
return false;
17421725
}
17431726

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-
17521727
LLVM_ATTRIBUTE_DEPRECATED(
17531728
void dump() const,
17541729
"only for use within the debugger");

0 commit comments

Comments
 (0)