@@ -1037,7 +1037,10 @@ static bool isSynthesizedNonUnique(const RootProtocolConformance *conformance) {
1037
1037
}
1038
1038
1039
1039
// / 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
+ ) {
1041
1044
// Objective-C protocols have never been able to have a dependent conformance.
1042
1045
if (proto->isObjC ())
1043
1046
return false ;
@@ -1047,13 +1050,14 @@ static bool protocolCanHaveDependentConformance(ProtocolDecl *proto) {
1047
1050
// is a marker protocol (since they don't have requirements), but we must
1048
1051
// retain backward compatibility with binaries built for earlier deployment
1049
1052
// 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
+ }
1057
1061
}
1058
1062
1059
1063
return Lowering::TypeConverter::protocolRequiresWitnessTable (proto);
@@ -1062,6 +1066,7 @@ static bool protocolCanHaveDependentConformance(ProtocolDecl *proto) {
1062
1066
static bool isDependentConformance (
1063
1067
IRGenModule &IGM,
1064
1068
const RootProtocolConformance *rootConformance,
1069
+ bool isResilient,
1065
1070
llvm::SmallPtrSet<const NormalProtocolConformance *, 4 > &visited){
1066
1071
// Self-conformances are never dependent.
1067
1072
auto conformance = dyn_cast<NormalProtocolConformance>(rootConformance);
@@ -1091,7 +1096,8 @@ static bool isDependentConformance(
1091
1096
continue ;
1092
1097
1093
1098
auto assocProtocol = req.getProtocolDecl ();
1094
- if (!protocolCanHaveDependentConformance (assocProtocol))
1099
+ if (!protocolCanHaveDependentConformance (
1100
+ assocProtocol, isResilient))
1095
1101
continue ;
1096
1102
1097
1103
auto assocConformance =
@@ -1105,6 +1111,7 @@ static bool isDependentConformance(
1105
1111
isDependentConformance (IGM,
1106
1112
assocConformance.getConcrete ()
1107
1113
->getRootConformance (),
1114
+ isResilient,
1108
1115
visited))
1109
1116
return true ;
1110
1117
}
@@ -1173,7 +1180,8 @@ static bool hasConditionalConformances(IRGenModule &IGM,
1173
1180
bool IRGenModule::isDependentConformance (
1174
1181
const RootProtocolConformance *conformance) {
1175
1182
llvm::SmallPtrSet<const NormalProtocolConformance *, 4 > visited;
1176
- return ::isDependentConformance (*this , conformance, visited);
1183
+ return ::isDependentConformance (
1184
+ *this , conformance, conformance->getProtocol ()->isResilient (), visited);
1177
1185
}
1178
1186
1179
1187
static llvm::Value *
0 commit comments