@@ -1037,7 +1037,10 @@ static bool isSynthesizedNonUnique(const RootProtocolConformance *conformance) {
10371037}
10381038
10391039// / Determine whether a protocol can ever have a dependent conformance.
1040- static bool protocolCanHaveDependentConformance (ProtocolDecl *proto) {
1040+ static bool protocolCanHaveDependentConformance (
1041+ ProtocolDecl *proto,
1042+ bool isResilient
1043+ ) {
10411044 // Objective-C protocols have never been able to have a dependent conformance.
10421045 if (proto->isObjC ())
10431046 return false ;
@@ -1047,13 +1050,14 @@ static bool protocolCanHaveDependentConformance(ProtocolDecl *proto) {
10471050 // is a marker protocol (since they don't have requirements), but we must
10481051 // retain backward compatibility with binaries built for earlier deployment
10491052 // targets that concluded that these protocols might involve dependent
1050- // conformances.
1051- ASTContext &ctx = proto->getASTContext ();
1052- if (auto runtimeCompatVersion = getSwiftRuntimeCompatibilityVersionForTarget (
1053- ctx.LangOpts .Target )) {
1054- if (runtimeCompatVersion < llvm::VersionTuple (6 , 0 ) &&
1055- proto->isSpecificProtocol (KnownProtocolKind::Sendable))
1056- return true ;
1053+ // conformances. Only do this for resilient protocols.
1054+ if (isResilient && proto->isSpecificProtocol (KnownProtocolKind::Sendable)) {
1055+ ASTContext &ctx = proto->getASTContext ();
1056+ if (auto runtimeCompatVersion = getSwiftRuntimeCompatibilityVersionForTarget (
1057+ ctx.LangOpts .Target )) {
1058+ if (runtimeCompatVersion < llvm::VersionTuple (6 , 0 ))
1059+ return true ;
1060+ }
10571061 }
10581062
10591063 return Lowering::TypeConverter::protocolRequiresWitnessTable (proto);
@@ -1062,6 +1066,7 @@ static bool protocolCanHaveDependentConformance(ProtocolDecl *proto) {
10621066static bool isDependentConformance (
10631067 IRGenModule &IGM,
10641068 const RootProtocolConformance *rootConformance,
1069+ bool isResilient,
10651070 llvm::SmallPtrSet<const NormalProtocolConformance *, 4 > &visited){
10661071 // Self-conformances are never dependent.
10671072 auto conformance = dyn_cast<NormalProtocolConformance>(rootConformance);
@@ -1091,7 +1096,8 @@ static bool isDependentConformance(
10911096 continue ;
10921097
10931098 auto assocProtocol = req.getProtocolDecl ();
1094- if (!protocolCanHaveDependentConformance (assocProtocol))
1099+ if (!protocolCanHaveDependentConformance (
1100+ assocProtocol, isResilient))
10951101 continue ;
10961102
10971103 auto assocConformance =
@@ -1105,6 +1111,7 @@ static bool isDependentConformance(
11051111 isDependentConformance (IGM,
11061112 assocConformance.getConcrete ()
11071113 ->getRootConformance (),
1114+ isResilient,
11081115 visited))
11091116 return true ;
11101117 }
@@ -1173,7 +1180,8 @@ static bool hasConditionalConformances(IRGenModule &IGM,
11731180bool IRGenModule::isDependentConformance (
11741181 const RootProtocolConformance *conformance) {
11751182 llvm::SmallPtrSet<const NormalProtocolConformance *, 4 > visited;
1176- return ::isDependentConformance (*this , conformance, visited);
1183+ return ::isDependentConformance (
1184+ *this , conformance, conformance->getProtocol ()->isResilient (), visited);
11771185}
11781186
11791187static llvm::Value *
0 commit comments