Skip to content

Commit afbd81a

Browse files
committed
AST/Sema: Use ProtocolConformanceRef::getTypeWitness()
1 parent 0bd6f25 commit afbd81a

7 files changed

+8
-15
lines changed

Diff for: lib/AST/ProtocolConformanceRef.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,7 @@ ProtocolConformanceRef::getTypeWitnessByName(Type type, Identifier name) const {
163163
if (!assocType)
164164
return ErrorType::get(proto->getASTContext());
165165

166-
return assocType->getDeclaredInterfaceType().subst(
167-
SubstitutionMap::getProtocolSubstitutions(proto, type, *this));
166+
return getTypeWitness(type, assocType);
168167
}
169168

170169
ConcreteDeclRef

Diff for: lib/AST/RequirementMachine/ConcreteContraction.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,7 @@ ConcreteContraction::substTypeParameterRec(Type type, Position position) const {
302302
return std::nullopt;
303303
}
304304

305-
return conformance.getAssociatedType(
306-
*substBaseType, assocType->getDeclaredInterfaceType());
305+
return conformance.getTypeWitness(*substBaseType, assocType);
307306
}
308307

309308
// An unresolved DependentMemberType stores an identifier. Handle this

Diff for: lib/AST/RequirementMachine/GenericSignatureQueries.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,7 @@ static Type substPrefixType(Type type, unsigned suffixLength, Type prefixType,
346346
auto *assocDecl = memberType->getAssocType();
347347
auto *proto = assocDecl->getProtocol();
348348
auto conformance = lookupConformance(substBaseType, proto);
349-
return conformance.getAssociatedType(
350-
substBaseType,
351-
assocDecl->getDeclaredInterfaceType());
349+
return conformance.getTypeWitness(substBaseType, assocDecl);
352350
}
353351

354352
Type RequirementMachine::getReducedTypeParameter(

Diff for: lib/AST/RequirementMachine/RequirementLowering.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -665,8 +665,7 @@ struct InferRequirementsWalker : public TypeWalker {
665665
auto addSameTypeConstraint = [&](Type firstType,
666666
AssociatedTypeDecl *assocType) {
667667
auto conformance = lookupConformance(firstType, differentiableProtocol);
668-
auto secondType = conformance.getAssociatedType(
669-
firstType, assocType->getDeclaredInterfaceType());
668+
auto secondType = conformance.getTypeWitness(firstType, assocType);
670669
reqs.push_back({Requirement(RequirementKind::SameType,
671670
firstType, secondType),
672671
SourceLoc()});

Diff for: lib/AST/Type.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -4467,8 +4467,7 @@ TypeBase::getAutoDiffTangentSpace(LookupConformanceFn lookupConformance) {
44674467
// Try to get the `TangentVector` associated type of `base`.
44684468
// Return the associated type if it is valid.
44694469
auto conformance = swift::lookupConformance(this, differentiableProtocol);
4470-
auto assocTy = conformance.getAssociatedType(
4471-
this, assocDecl->getDeclaredInterfaceType());
4470+
auto assocTy = conformance.getTypeWitness(this, assocDecl);
44724471
if (!assocTy->hasError())
44734472
return cache(TangentSpace::getTangentVector(assocTy));
44744473

Diff for: lib/Sema/ConstraintSystem.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -4165,8 +4165,7 @@ struct TypeSimplifier {
41654165
return memberTy;
41664166
}
41674167

4168-
auto result = conformance.getAssociatedType(
4169-
lookupBaseType, assocType->getDeclaredInterfaceType());
4168+
auto result = conformance.getTypeWitness(lookupBaseType, assocType);
41704169
if (result && !result->hasError())
41714170
return result;
41724171
}

Diff for: lib/Sema/TypeCheckEffects.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1167,8 +1167,8 @@ class ApplyClassifier {
11671167
conditional = ConditionalEffectKind::Always;
11681168

11691169
// Use the Failure type witness, when present.
1170-
Type thrownError = conformanceRef.getAssociatedType(
1171-
type, failureAssocType->getDeclaredInterfaceType());
1170+
Type thrownError = conformanceRef.getTypeWitness(
1171+
type, failureAssocType);
11721172
return Classification::forThrows(
11731173
thrownError, conditional,
11741174
/*FIXME*/PotentialEffectReason::forConformance());

0 commit comments

Comments
 (0)