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