@@ -258,6 +258,14 @@ void ConformanceLookupTable::inheritConformances(ClassDecl *classDecl,
258258 auto addInheritedConformance = [&](ConformanceEntry *entry) {
259259 auto protocol = entry->getProtocol ();
260260
261+ // Don't add unavailable conformances.
262+ if (auto dc = entry->Source .getDeclContext ()) {
263+ if (auto ext = dyn_cast<ExtensionDecl>(dc)) {
264+ if (AvailableAttr::isUnavailable (ext))
265+ return ;
266+ }
267+ }
268+
261269 // Don't add redundant conformances here. This is merely an
262270 // optimization; resolveConformances() would zap the duplicates
263271 // anyway.
@@ -619,14 +627,6 @@ ConformanceLookupTable::Ordering ConformanceLookupTable::compareConformances(
619627
620628 // Allow replacement of an explicit conformance to a marker protocol.
621629 // (This permits redundant explicit declarations of `Sendable`.)
622- //
623- // FIXME: We need to warn on attempts to make an unavailable Sendable
624- // conformance available, which does not work.
625- //
626- // We probably also want to warn if there is an existing, explicit
627- // conformance, so clients are prompted to remove retroactive unchecked
628- // Sendable conformances when the proper Sendable conformance is added
629- // in the original module.
630630 return (kind == ConformanceEntryKind::Explicit
631631 && entry->getProtocol ()->isMarkerProtocol ());
632632 };
@@ -879,6 +879,8 @@ DeclContext *ConformanceLookupTable::getConformingContext(
879879 return nullptr ;
880880 auto inheritedConformance = module ->lookupConformance (
881881 superclassTy, protocol, /* allowMissing=*/ false );
882+ if (inheritedConformance.hasUnavailableConformance ())
883+ inheritedConformance = ProtocolConformanceRef::forInvalid ();
882884 if (inheritedConformance)
883885 return superclassDecl;
884886 } while ((superclassDecl = superclassDecl->getSuperclassDecl ()));
0 commit comments