@@ -1030,7 +1030,10 @@ static bool isSynthesizedNonUnique(const RootProtocolConformance *conformance) {
1030
1030
}
1031
1031
1032
1032
// / 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
+ ) {
1034
1037
// Objective-C protocols have never been able to have a dependent conformance.
1035
1038
if (proto->isObjC ())
1036
1039
return false ;
@@ -1040,13 +1043,14 @@ static bool protocolCanHaveDependentConformance(ProtocolDecl *proto) {
1040
1043
// is a marker protocol (since they don't have requirements), but we must
1041
1044
// retain backward compatibility with binaries built for earlier deployment
1042
1045
// 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
+ }
1050
1054
}
1051
1055
1052
1056
return Lowering::TypeConverter::protocolRequiresWitnessTable (proto);
@@ -1055,6 +1059,7 @@ static bool protocolCanHaveDependentConformance(ProtocolDecl *proto) {
1055
1059
static bool isDependentConformance (
1056
1060
IRGenModule &IGM,
1057
1061
const RootProtocolConformance *rootConformance,
1062
+ bool isResilient,
1058
1063
llvm::SmallPtrSet<const NormalProtocolConformance *, 4 > &visited){
1059
1064
// Self-conformances are never dependent.
1060
1065
auto conformance = dyn_cast<NormalProtocolConformance>(rootConformance);
@@ -1084,7 +1089,8 @@ static bool isDependentConformance(
1084
1089
continue ;
1085
1090
1086
1091
auto assocProtocol = req.getProtocolDecl ();
1087
- if (!protocolCanHaveDependentConformance (assocProtocol))
1092
+ if (!protocolCanHaveDependentConformance (
1093
+ assocProtocol, isResilient))
1088
1094
continue ;
1089
1095
1090
1096
auto assocConformance =
@@ -1098,6 +1104,7 @@ static bool isDependentConformance(
1098
1104
isDependentConformance (IGM,
1099
1105
assocConformance.getConcrete ()
1100
1106
->getRootConformance (),
1107
+ isResilient,
1101
1108
visited))
1102
1109
return true ;
1103
1110
}
@@ -1166,7 +1173,8 @@ static bool hasConditionalConformances(IRGenModule &IGM,
1166
1173
bool IRGenModule::isDependentConformance (
1167
1174
const RootProtocolConformance *conformance) {
1168
1175
llvm::SmallPtrSet<const NormalProtocolConformance *, 4 > visited;
1169
- return ::isDependentConformance (*this , conformance, visited);
1176
+ return ::isDependentConformance (
1177
+ *this , conformance, conformance->getProtocol ()->isResilient (), visited);
1170
1178
}
1171
1179
1172
1180
static llvm::Value *
0 commit comments