@@ -3164,9 +3164,13 @@ void ASTMangler::appendGenericSignatureParts(
3164
3164
3165
3165
// / Determine whether an associated type reference into the given set of
3166
3166
// / 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
+
3168
3172
unsigned numProtocols = 0 ;
3169
- for (auto proto : protocols ) {
3173
+ for (auto proto : sig-> getRequiredProtocols (t) ) {
3170
3174
// Skip marker protocols, which cannot have associated types.
3171
3175
if (proto->isMarkerProtocol ())
3172
3176
continue ;
@@ -3186,7 +3190,7 @@ ASTMangler::dropProtocolFromAssociatedType(DependentMemberType *dmt,
3186
3190
auto baseTy = dmt->getBase ();
3187
3191
bool unambiguous =
3188
3192
(!dmt->getAssocType () ||
3189
- associatedTypeRefIsUnambiguous (sig-> getRequiredProtocols ( baseTy) ));
3193
+ associatedTypeRefIsUnambiguous (sig, baseTy));
3190
3194
3191
3195
if (auto *baseDMT = baseTy->getAs <DependentMemberType>())
3192
3196
baseTy = dropProtocolFromAssociatedType (baseDMT, sig);
@@ -3223,7 +3227,7 @@ void ASTMangler::appendAssociatedTypeName(DependentMemberType *dmt,
3223
3227
// associated type name by protocol.
3224
3228
if (!OptimizeProtocolNames || !sig ||
3225
3229
!associatedTypeRefIsUnambiguous (
3226
- sig-> getRequiredProtocols ( dmt->getBase () ))) {
3230
+ sig, dmt->getBase ())) {
3227
3231
appendAnyGenericType (assocTy->getProtocol ());
3228
3232
}
3229
3233
return ;
0 commit comments