@@ -3856,15 +3856,22 @@ filterProtocolRequirements(
38563856
38573857 auto OverloadTy = Req->getOverloadSignatureType ();
38583858 if (OverloadTy) {
3859- OverloadTy =
3860- OverloadTy.subst (getProtocolSubstitutionMap (Req))->getCanonicalType ();
3859+ auto Subs = getProtocolSubstitutionMap (Req);
3860+ // FIXME: This is wrong if the overload has its own generic parameters
3861+ if (auto GenericFnTy = dyn_cast<GenericFunctionType>(OverloadTy))
3862+ OverloadTy = GenericFnTy.substGenericArgs (Subs);
3863+ else
3864+ OverloadTy = OverloadTy.subst (Subs)->getCanonicalType ();
38613865 }
38623866 if (llvm::any_of (DeclsByName[Req->getName ()], [&](ValueDecl *OtherReq) {
38633867 auto OtherOverloadTy = OtherReq->getOverloadSignatureType ();
38643868 if (OtherOverloadTy) {
3865- OtherOverloadTy =
3866- OtherOverloadTy.subst (getProtocolSubstitutionMap (OtherReq))
3867- ->getCanonicalType ();
3869+ auto Subs = getProtocolSubstitutionMap (OtherReq);
3870+ // FIXME: This is wrong if the overload has its own generic parameters
3871+ if (auto GenericFnTy = dyn_cast<GenericFunctionType>(OtherOverloadTy))
3872+ OtherOverloadTy = GenericFnTy.substGenericArgs (Subs);
3873+ else
3874+ OtherOverloadTy = OtherOverloadTy.subst (Subs)->getCanonicalType ();
38683875 }
38693876 return conflicting (Req->getASTContext (), Req->getOverloadSignature (),
38703877 OverloadTy, OtherReq->getOverloadSignature (),
@@ -7401,7 +7408,10 @@ bool swift::forEachConformance(
74017408 if (forEachConformance (subs, body, visitedConformances))
74027409 return true ;
74037410
7404- type = type.subst (subs);
7411+ if (auto *genericFnType = type->getAs <GenericFunctionType>())
7412+ type = genericFnType->substGenericArgs (subs);
7413+ else
7414+ type = type.subst (subs);
74057415 }
74067416
74077417 if (forEachConformance (type, body, visitedConformances))
0 commit comments