Skip to content

Commit a911693

Browse files
committed
AST: PackConformance::getAssociatedType() => getTypeWitness()
1 parent 6928588 commit a911693

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

include/swift/AST/PackConformance.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ class alignas(1 << DeclAlignInBits) PackConformance final
7474

7575
PackConformance *getCanonicalConformance() const;
7676

77-
PackType *getAssociatedType(Type assocType) const;
77+
PackType *getTypeWitness(AssociatedTypeDecl *assocType,
78+
SubstOptions options=std::nullopt) const;
7879

7980
PackConformance *
8081
getAssociatedConformance(Type assocType, ProtocolDecl *protocol) const;

lib/AST/PackConformance.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ PackConformance *PackConformance::getCanonicalConformance() const {
9797
/// Project the corresponding associated type from each pack element
9898
/// of the conforming type, collecting the results into a new pack type
9999
/// that has the same pack expansion structure as the conforming type.
100-
PackType *PackConformance::getAssociatedType(Type assocType) const {
100+
PackType *PackConformance::getTypeWitness(
101+
AssociatedTypeDecl *assocType,
102+
SubstOptions options) const {
101103
SmallVector<Type, 4> packElements;
102104

103105
auto conformances = getPatternConformances();
@@ -110,8 +112,8 @@ PackType *PackConformance::getAssociatedType(Type assocType) const {
110112
// conformance.
111113
if (auto *packExpansion = packElement->getAs<PackExpansionType>()) {
112114
auto assocTypePattern =
113-
conformances[i].getAssociatedType(packExpansion->getPatternType(),
114-
assocType);
115+
conformances[i].getTypeWitness(packExpansion->getPatternType(),
116+
assocType, options);
115117

116118
packElements.push_back(PackExpansionType::get(
117119
assocTypePattern, packExpansion->getCountType()));
@@ -120,7 +122,7 @@ PackType *PackConformance::getAssociatedType(Type assocType) const {
120122
// the associated type witness from the pattern conformance.
121123
} else {
122124
auto assocTypeScalar =
123-
conformances[i].getAssociatedType(packElement, assocType);
125+
conformances[i].getTypeWitness(packElement, assocType, options);
124126
packElements.push_back(assocTypeScalar);
125127
}
126128
}

lib/AST/ProtocolConformanceRef.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ Type ProtocolConformanceRef::getTypeWitness(Type conformingType,
199199
if (isPack()) {
200200
auto *pack = getPack();
201201
ASSERT(conformingType->isEqual(pack->getType()));
202-
return pack->getAssociatedType(assocType->getDeclaredInterfaceType());
202+
return pack->getTypeWitness(assocType);
203203
}
204204

205205
auto failed = [&]() {

lib/AST/TypeSubstitution.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -576,10 +576,8 @@ Type TypeSubstituter::transformDependentMemberType(DependentMemberType *dependen
576576

577577
// Retrieve the type witness.
578578
if (conformance.isPack()) {
579-
auto *packConformance = conformance.getPack();
580-
581-
witnessTy = packConformance->getAssociatedType(
582-
assocType->getDeclaredInterfaceType());
579+
witnessTy = conformance.getPack()->getTypeWitness(assocType,
580+
IFS.getOptions());
583581
} else if (conformance.isConcrete()) {
584582
auto witness =
585583
conformance.getConcrete()->getTypeWitnessAndDecl(assocType,

0 commit comments

Comments
 (0)