@@ -3164,9 +3164,13 @@ void ASTMangler::appendGenericSignatureParts(
31643164
31653165// / Determine whether an associated type reference into the given set of
31663166// / protocols is unambiguous.
3167- static bool associatedTypeRefIsUnambiguous (ArrayRef<ProtocolDecl *> protocols) {
3167+ static bool associatedTypeRefIsUnambiguous (GenericSignature sig, Type t) {
3168+ // FIXME: This should be an assertion.
3169+ if (!sig->isValidTypeParameter (t))
3170+ return false ;
3171+
31683172 unsigned numProtocols = 0 ;
3169- for (auto proto : protocols ) {
3173+ for (auto proto : sig-> getRequiredProtocols (t) ) {
31703174 // Skip marker protocols, which cannot have associated types.
31713175 if (proto->isMarkerProtocol ())
31723176 continue ;
@@ -3186,7 +3190,7 @@ ASTMangler::dropProtocolFromAssociatedType(DependentMemberType *dmt,
31863190 auto baseTy = dmt->getBase ();
31873191 bool unambiguous =
31883192 (!dmt->getAssocType () ||
3189- associatedTypeRefIsUnambiguous (sig-> getRequiredProtocols ( baseTy) ));
3193+ associatedTypeRefIsUnambiguous (sig, baseTy));
31903194
31913195 if (auto *baseDMT = baseTy->getAs <DependentMemberType>())
31923196 baseTy = dropProtocolFromAssociatedType (baseDMT, sig);
@@ -3223,7 +3227,7 @@ void ASTMangler::appendAssociatedTypeName(DependentMemberType *dmt,
32233227 // associated type name by protocol.
32243228 if (!OptimizeProtocolNames || !sig ||
32253229 !associatedTypeRefIsUnambiguous (
3226- sig-> getRequiredProtocols ( dmt->getBase () ))) {
3230+ sig, dmt->getBase ())) {
32273231 appendAnyGenericType (assocTy->getProtocol ());
32283232 }
32293233 return ;
0 commit comments