Skip to content

Commit 8b1514c

Browse files
committed
AST: Remove origType parameter from ProtocolConformanceRef::getAssociatedConformance()
1 parent ff14828 commit 8b1514c

File tree

5 files changed

+11
-14
lines changed

5 files changed

+11
-14
lines changed

include/swift/AST/ProtocolConformanceRef.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,7 @@ class ProtocolConformanceRef {
215215
/// Given a dependent type (expressed in terms of this conformance's
216216
/// protocol) and conformance, follow it from the conforming type.
217217
ProtocolConformanceRef
218-
getAssociatedConformance(Type origType, Type dependentType,
219-
ProtocolDecl *requirement) const;
218+
getAssociatedConformance(Type dependentType, ProtocolDecl *requirement) const;
220219

221220
SWIFT_DEBUG_DUMP;
222221
void dump(llvm::raw_ostream &out, unsigned indent = 0,

lib/AST/PackConformance.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,15 @@ PackConformance *PackConformance::getAssociatedConformance(
151151
assocTypePattern, packExpansion->getCountType()));
152152

153153
auto assocConformancePattern =
154-
conformances[i].getAssociatedConformance(packExpansion->getPatternType(),
155-
assocType, protocol);
154+
conformances[i].getAssociatedConformance(assocType, protocol);
156155
packConformances.push_back(assocConformancePattern);
157156
} else {
158157
auto assocTypeScalar =
159158
conformances[i].getAssociatedType(packElement, assocType);
160159
packElements.push_back(assocTypeScalar);
161160

162161
auto assocConformanceScalar =
163-
conformances[i].getAssociatedConformance(packElement, assocType, protocol);
162+
conformances[i].getAssociatedConformance(assocType, protocol);
164163
packConformances.push_back(assocConformanceScalar);
165164
}
166165
}

lib/AST/ProtocolConformanceRef.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,25 +244,26 @@ Type ProtocolConformanceRef::getAssociatedType(Type conformingType,
244244
}
245245

246246
ProtocolConformanceRef
247-
ProtocolConformanceRef::getAssociatedConformance(Type conformingType,
248-
Type assocType,
247+
ProtocolConformanceRef::getAssociatedConformance(Type assocType,
249248
ProtocolDecl *protocol) const {
249+
if (isInvalid())
250+
return *this;
251+
250252
// If this is a pack conformance, project the associated conformances from
251253
// each pack element.
252254
if (isPack()) {
253255
auto *pack = getPack();
254-
assert(conformingType->isEqual(pack->getType()));
255256
return ProtocolConformanceRef(
256257
pack->getAssociatedConformance(assocType, protocol));
257258
}
258259

259260
// If this is a concrete conformance, project the associated conformance.
260261
if (isConcrete()) {
261-
auto conformance = getConcrete();
262-
assert(conformance->getType()->isEqual(conformingType));
263-
return conformance->getAssociatedConformance(assocType, protocol);
262+
return getConcrete()->getAssociatedConformance(assocType, protocol);
264263
}
265264

265+
auto conformingType = getType();
266+
266267
auto computeSubjectType = [&](Type conformingType) -> Type {
267268
return assocType.transformRec(
268269
[&](TypeBase *t) -> std::optional<Type> {

lib/IRGen/GenProto.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3454,8 +3454,7 @@ MetadataResponse MetadataPath::followComponent(IRGenFunction &IGF,
34543454
sourceKey.Type = associatedType;
34553455

34563456
auto associatedConformance =
3457-
sourceConformance.getAssociatedConformance(sourceType, association,
3458-
associatedRequirement);
3457+
sourceConformance.getAssociatedConformance(association, associatedRequirement);
34593458
sourceKey.Kind =
34603459
LocalTypeDataKind::forProtocolWitnessTable(associatedConformance);
34613460

lib/SILGen/SILGenExpr.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4152,7 +4152,6 @@ getOrCreateKeyPathEqualsAndHash(SILGenModule &SGM,
41524152

41534153
// Get the Equatable conformance from the Hashable conformance.
41544154
auto equatable = hashable.getAssociatedConformance(
4155-
formalTy,
41564155
GenericTypeParamType::getType(/*depth*/ 0, /*index*/ 0, C),
41574156
equatableProtocol);
41584157

0 commit comments

Comments
 (0)