@@ -4192,18 +4192,26 @@ void ASTMangler::appendAnyProtocolConformance(
41924192 conformance.getRequirement ()->isMarkerProtocol ())
41934193 return ;
41944194
4195- // While all invertible protocols are marker protocols, do not mangle them for
4196- // compatability reasons. See equivalent hack in `conformanceRequirementIndex`
4197- // where only invertible protocols are unconditionally skipped.
4198- if (conformance.getRequirement ()->getInvertibleProtocolKind ())
4199- return ;
4195+ // While all invertible protocols are marker protocols, do not mangle them
4196+ // as a dependent conformance. See `conformanceRequirementIndex` which skips
4197+ // these, too. In theory, invertible conformances should never be mangled,
4198+ // but we *might* have let that slip by for the other cases below, so the
4199+ // early-exits are highly conservative.
4200+ const bool forInvertible =
4201+ conformance.getRequirement ()->getInvertibleProtocolKind ().has_value ();
42004202
42014203 if (conformingType->isTypeParameter ()) {
42024204 assert (genericSig && " Need a generic signature to resolve conformance" );
4205+ if (forInvertible)
4206+ return ;
4207+
42034208 auto path = genericSig->getConformancePath (conformingType,
42044209 conformance.getAbstract ());
42054210 appendDependentProtocolConformance (path, genericSig);
42064211 } else if (auto opaqueType = conformingType->getAs <OpaqueTypeArchetypeType>()) {
4212+ if (forInvertible)
4213+ return ;
4214+
42074215 GenericSignature opaqueSignature =
42084216 opaqueType->getDecl ()->getOpaqueInterfaceGenericSignature ();
42094217 ConformancePath conformancePath =
0 commit comments