@@ -236,47 +236,14 @@ Type ProtocolConformanceRef::getTypeWitness(Type conformingType,
236
236
237
237
Type ProtocolConformanceRef::getAssociatedType (Type conformingType,
238
238
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
-
254
239
if (isInvalid ())
255
240
return ErrorType::get (assocType->getASTContext ());
256
241
257
242
auto proto = getRequirement ();
258
243
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.
277
244
auto substMap =
278
245
SubstitutionMap::getProtocolSubstitutions (proto, conformingType, *this );
279
- return type .subst (substMap);
246
+ return assocType .subst (substMap);
280
247
}
281
248
282
249
ProtocolConformanceRef
0 commit comments