@@ -950,8 +950,13 @@ namespace {
950
950
951
951
// / Return true if the witness table requires runtime instantiation to
952
952
// / handle resiliently-added requirements with default implementations.
953
+ // /
954
+ // / If ignoreGenericity is true, skip the optimization for non-generic
955
+ // / conformances are considered non-resilient.
953
956
bool IRGenModule::isResilientConformance (
954
- const NormalProtocolConformance *conformance) {
957
+ const NormalProtocolConformance *conformance,
958
+ bool ignoreGenericity
959
+ ) {
955
960
// If the protocol is not resilient, the conformance is not resilient
956
961
// either.
957
962
bool shouldTreatProtocolNonResilient =
@@ -983,16 +988,18 @@ bool IRGenModule::isResilientConformance(
983
988
// This is an optimization -- a conformance of a non-generic type cannot
984
989
// resiliently become dependent.
985
990
if (!conformance->getDeclContext ()->isGenericContext () &&
986
- conformanceModule == conformance->getProtocol ()->getParentModule ())
991
+ conformanceModule == conformance->getProtocol ()->getParentModule () &&
992
+ !ignoreGenericity)
987
993
return false ;
988
994
989
995
// We have a resilient conformance.
990
996
return true ;
991
997
}
992
998
993
- bool IRGenModule::isResilientConformance (const RootProtocolConformance *root) {
999
+ bool IRGenModule::isResilientConformance (const RootProtocolConformance *root,
1000
+ bool ignoreGenericity) {
994
1001
if (auto normal = dyn_cast<NormalProtocolConformance>(root))
995
- return isResilientConformance (normal);
1002
+ return isResilientConformance (normal, ignoreGenericity );
996
1003
// Self-conformances never require this.
997
1004
return false ;
998
1005
}
@@ -1174,7 +1181,9 @@ bool IRGenModule::isDependentConformance(
1174
1181
const RootProtocolConformance *conformance) {
1175
1182
llvm::SmallPtrSet<const NormalProtocolConformance *, 4 > visited;
1176
1183
return ::isDependentConformance (
1177
- *this , conformance, conformance->getProtocol ()->isResilient (), visited);
1184
+ *this , conformance,
1185
+ isResilientConformance (conformance, /* ignoreGenericity=*/ true ),
1186
+ visited);
1178
1187
}
1179
1188
1180
1189
static llvm::Value *
0 commit comments