@@ -271,12 +271,8 @@ SubstitutionMap::lookupConformance(CanType type, ProtocolDecl *proto) const {
271271
272272 // If the protocol is invertible, fall back to a global lookup instead of
273273 // evaluating a conformance path, to avoid an infinite substitution issue.
274- if (proto->getInvertibleProtocolKind ()) {
275- auto substType = type.subst (*this );
276- if (!substType->isTypeParameter ())
277- return swift::lookupConformance (substType, proto);
278- return ProtocolConformanceRef (proto);
279- }
274+ if (proto->getInvertibleProtocolKind ())
275+ return swift::lookupConformance (type.subst (*this ), proto);
280276
281277 auto path = genericSig->getConformancePath (type, proto);
282278
@@ -300,18 +296,7 @@ SubstitutionMap::lookupConformance(CanType type, ProtocolDecl *proto) const {
300296 if (conformance.isAbstract ()) {
301297 // FIXME: Rip this out once we can get a concrete conformance from
302298 // an archetype.
303- auto substType = type.subst (*this );
304- if (substType->hasError ())
305- return ProtocolConformanceRef (proto);
306-
307- if ((!substType->is <ArchetypeType>() ||
308- substType->castTo <ArchetypeType>()->getSuperclass ()) &&
309- !substType->isTypeParameter () &&
310- !substType->isExistentialType ()) {
311- return swift::lookupConformance (substType, proto);
312- }
313-
314- return ProtocolConformanceRef (proto);
299+ return swift::lookupConformance (type.subst (*this ), proto);
315300 }
316301
317302 // For the second step, we're looking into the requirement signature for
@@ -506,14 +491,11 @@ LookUpConformanceInOverrideSubs::operator()(CanType type,
506491 Type substType,
507492 ProtocolDecl *proto) const {
508493 if (type->getRootGenericParam ()->getDepth () >= info.BaseDepth )
509- return ProtocolConformanceRef ( proto);
494+ return ProtocolConformanceRef::forAbstract (substType, proto);
510495
511496 if (auto conformance = info.BaseSubMap .lookupConformance (type, proto))
512497 return conformance;
513498
514- if (substType->isTypeParameter ())
515- return ProtocolConformanceRef (proto);
516-
517499 return lookupConformance (substType, proto);
518500}
519501
@@ -714,7 +696,8 @@ ProtocolConformanceRef OuterSubstitutions::operator()(
714696 Type conformingReplacementType,
715697 ProtocolDecl *conformedProtocol) const {
716698 if (isUnsubstitutedTypeParameter (dependentType))
717- return ProtocolConformanceRef (conformedProtocol);
699+ return ProtocolConformanceRef::forAbstract (
700+ conformingReplacementType, conformedProtocol);
718701
719702 return LookUpConformanceInSubstitutionMap (subs)(
720703 dependentType, conformingReplacementType, conformedProtocol);
0 commit comments