@@ -1030,7 +1030,10 @@ static bool isSynthesizedNonUnique(const RootProtocolConformance *conformance) {
10301030}
10311031
10321032// / Determine whether a protocol can ever have a dependent conformance.
1033- static bool protocolCanHaveDependentConformance (ProtocolDecl *proto) {
1033+ static bool protocolCanHaveDependentConformance (
1034+ ProtocolDecl *proto,
1035+ bool isResilient
1036+ ) {
10341037 // Objective-C protocols have never been able to have a dependent conformance.
10351038 if (proto->isObjC ())
10361039 return false ;
@@ -1040,13 +1043,14 @@ static bool protocolCanHaveDependentConformance(ProtocolDecl *proto) {
10401043 // is a marker protocol (since they don't have requirements), but we must
10411044 // retain backward compatibility with binaries built for earlier deployment
10421045 // targets that concluded that these protocols might involve dependent
1043- // conformances.
1044- ASTContext &ctx = proto->getASTContext ();
1045- if (auto runtimeCompatVersion = getSwiftRuntimeCompatibilityVersionForTarget (
1046- ctx.LangOpts .Target )) {
1047- if (runtimeCompatVersion < llvm::VersionTuple (6 , 0 ) &&
1048- proto->isSpecificProtocol (KnownProtocolKind::Sendable))
1049- return true ;
1046+ // conformances. Only do this for resilient protocols.
1047+ if (isResilient && proto->isSpecificProtocol (KnownProtocolKind::Sendable)) {
1048+ ASTContext &ctx = proto->getASTContext ();
1049+ if (auto runtimeCompatVersion = getSwiftRuntimeCompatibilityVersionForTarget (
1050+ ctx.LangOpts .Target )) {
1051+ if (runtimeCompatVersion < llvm::VersionTuple (6 , 0 ))
1052+ return true ;
1053+ }
10501054 }
10511055
10521056 return Lowering::TypeConverter::protocolRequiresWitnessTable (proto);
@@ -1055,6 +1059,7 @@ static bool protocolCanHaveDependentConformance(ProtocolDecl *proto) {
10551059static bool isDependentConformance (
10561060 IRGenModule &IGM,
10571061 const RootProtocolConformance *rootConformance,
1062+ bool isResilient,
10581063 llvm::SmallPtrSet<const NormalProtocolConformance *, 4 > &visited){
10591064 // Self-conformances are never dependent.
10601065 auto conformance = dyn_cast<NormalProtocolConformance>(rootConformance);
@@ -1084,7 +1089,8 @@ static bool isDependentConformance(
10841089 continue ;
10851090
10861091 auto assocProtocol = req.getProtocolDecl ();
1087- if (!protocolCanHaveDependentConformance (assocProtocol))
1092+ if (!protocolCanHaveDependentConformance (
1093+ assocProtocol, isResilient))
10881094 continue ;
10891095
10901096 auto assocConformance =
@@ -1098,6 +1104,7 @@ static bool isDependentConformance(
10981104 isDependentConformance (IGM,
10991105 assocConformance.getConcrete ()
11001106 ->getRootConformance (),
1107+ isResilient,
11011108 visited))
11021109 return true ;
11031110 }
@@ -1166,7 +1173,8 @@ static bool hasConditionalConformances(IRGenModule &IGM,
11661173bool IRGenModule::isDependentConformance (
11671174 const RootProtocolConformance *conformance) {
11681175 llvm::SmallPtrSet<const NormalProtocolConformance *, 4 > visited;
1169- return ::isDependentConformance (*this , conformance, visited);
1176+ return ::isDependentConformance (
1177+ *this , conformance, conformance->getProtocol ()->isResilient (), visited);
11701178}
11711179
11721180static llvm::Value *
0 commit comments