Skip to content

Commit 6928588

Browse files
committed
AST: Gut ProtocolConformanceRef::getAssociatedType()
1 parent afbd81a commit 6928588

File tree

1 file changed

+1
-34
lines changed

1 file changed

+1
-34
lines changed

lib/AST/ProtocolConformanceRef.cpp

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -236,47 +236,14 @@ Type ProtocolConformanceRef::getTypeWitness(Type conformingType,
236236

237237
Type ProtocolConformanceRef::getAssociatedType(Type conformingType,
238238
Type assocType) const {
239-
if (isPack()) {
240-
auto *pack = getPack();
241-
ASSERT(conformingType->isEqual(pack->getType()));
242-
return pack->getAssociatedType(assocType);
243-
}
244-
245-
auto type = assocType->getCanonicalType();
246-
247-
// Fast path for generic parameters.
248-
if (auto paramTy = dyn_cast<GenericTypeParamType>(type)) {
249-
ASSERT(paramTy->getDepth() == 0 && paramTy->getIndex() == 0 &&
250-
"type parameter in protocol was not Self");
251-
return conformingType;
252-
}
253-
254239
if (isInvalid())
255240
return ErrorType::get(assocType->getASTContext());
256241

257242
auto proto = getRequirement();
258243

259-
if (isConcrete()) {
260-
if (auto selfType = conformingType->getAs<DynamicSelfType>())
261-
conformingType = selfType->getSelfType();
262-
ASSERT(getConcrete()->getType()->isEqual(conformingType));
263-
264-
// Fast path for dependent member types on 'Self' of our associated types.
265-
auto memberType = cast<DependentMemberType>(type);
266-
if (memberType.getBase()->isEqual(proto->getSelfInterfaceType()) &&
267-
memberType->getAssocType()->getProtocol() == proto) {
268-
auto witnessType = getConcrete()->getTypeWitness(
269-
memberType->getAssocType());
270-
if (!witnessType)
271-
return ErrorType::get(assocType->getASTContext());
272-
return witnessType;
273-
}
274-
}
275-
276-
// General case: consult the substitution map.
277244
auto substMap =
278245
SubstitutionMap::getProtocolSubstitutions(proto, conformingType, *this);
279-
return type.subst(substMap);
246+
return assocType.subst(substMap);
280247
}
281248

282249
ProtocolConformanceRef

0 commit comments

Comments
 (0)