@@ -950,8 +950,13 @@ namespace {
950950
951951// / Return true if the witness table requires runtime instantiation to
952952// / 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.
953956bool IRGenModule::isResilientConformance (
954- const NormalProtocolConformance *conformance) {
957+ const NormalProtocolConformance *conformance,
958+ bool ignoreGenericity
959+ ) {
955960 // If the protocol is not resilient, the conformance is not resilient
956961 // either.
957962 bool shouldTreatProtocolNonResilient =
@@ -983,16 +988,18 @@ bool IRGenModule::isResilientConformance(
983988 // This is an optimization -- a conformance of a non-generic type cannot
984989 // resiliently become dependent.
985990 if (!conformance->getDeclContext ()->isGenericContext () &&
986- conformanceModule == conformance->getProtocol ()->getParentModule ())
991+ conformanceModule == conformance->getProtocol ()->getParentModule () &&
992+ !ignoreGenericity)
987993 return false ;
988994
989995 // We have a resilient conformance.
990996 return true ;
991997}
992998
993- bool IRGenModule::isResilientConformance (const RootProtocolConformance *root) {
999+ bool IRGenModule::isResilientConformance (const RootProtocolConformance *root,
1000+ bool ignoreGenericity) {
9941001 if (auto normal = dyn_cast<NormalProtocolConformance>(root))
995- return isResilientConformance (normal);
1002+ return isResilientConformance (normal, ignoreGenericity );
9961003 // Self-conformances never require this.
9971004 return false ;
9981005}
@@ -1174,7 +1181,9 @@ bool IRGenModule::isDependentConformance(
11741181 const RootProtocolConformance *conformance) {
11751182 llvm::SmallPtrSet<const NormalProtocolConformance *, 4 > visited;
11761183 return ::isDependentConformance (
1177- *this , conformance, conformance->getProtocol ()->isResilient (), visited);
1184+ *this , conformance,
1185+ isResilientConformance (conformance, /* ignoreGenericity=*/ true ),
1186+ visited);
11781187}
11791188
11801189static llvm::Value *
0 commit comments