@@ -1015,7 +1015,9 @@ ModuleDecl::lookupExistentialConformance(Type type, ProtocolDecl *protocol) {
10151015 // If the existential is class-constrained, the class might conform
10161016 // concretely.
10171017 if (auto superclass = layout.explicitSuperclass ) {
1018- if (auto result = lookupConformance (superclass, protocol))
1018+ if (auto result = lookupConformance (
1019+ superclass, protocol, /* allowMissing=*/ false ,
1020+ /* allowUnavailable=*/ false ))
10191021 return result;
10201022 }
10211023
@@ -1071,7 +1073,8 @@ ProtocolConformanceRef ProtocolConformanceRef::forMissingOrInvalid(
10711073
10721074ProtocolConformanceRef ModuleDecl::lookupConformance (Type type,
10731075 ProtocolDecl *protocol,
1074- bool allowMissing) {
1076+ bool allowMissing,
1077+ bool allowUnavailable) {
10751078 // If we are recursively checking for implicit conformance of a nominal
10761079 // type to Sendable, fail without evaluating this request. This
10771080 // squashes cycles.
@@ -1088,13 +1091,18 @@ ProtocolConformanceRef ModuleDecl::lookupConformance(Type type,
10881091 auto result = evaluateOrDefault (
10891092 getASTContext ().evaluator , request, ProtocolConformanceRef::forInvalid ());
10901093
1091- // If we aren't supposed to allow missing conformances through for this
1092- // protocol, replace the result with an "invalid" result.
1094+ // If we aren't supposed to allow missing conformances but we have one,
1095+ // replace the result with an "invalid" result.
10931096 if (!allowMissing &&
10941097 shouldCreateMissingConformances (type, protocol) &&
10951098 result.hasMissingConformance (this ))
10961099 return ProtocolConformanceRef::forInvalid ();
10971100
1101+ // If we aren't supposed to allow unavailable conformances but we have one,
1102+ // replace the result with an "invalid" result.
1103+ if (!allowUnavailable && result.hasUnavailableConformance ())
1104+ return ProtocolConformanceRef::forInvalid ();
1105+
10981106 return result;
10991107}
11001108
@@ -1248,7 +1256,9 @@ LookupConformanceInModuleRequest::evaluate(
12481256 // able to be resolved by a substitution that makes the archetype
12491257 // concrete.
12501258 if (auto super = archetype->getSuperclass ()) {
1251- if (auto inheritedConformance = mod->lookupConformance (super, protocol)) {
1259+ if (auto inheritedConformance = mod->lookupConformance (
1260+ super, protocol, /* allowMissing=*/ false ,
1261+ /* allowUnavailable=*/ false )) {
12521262 return ProtocolConformanceRef (ctx.getInheritedConformance (
12531263 type, inheritedConformance.getConcrete ()));
12541264 }
0 commit comments