@@ -573,6 +573,29 @@ static void addSendableFixIt(
573573 }
574574}
575575
576+ // / Determine whether there is an unavailable conformance here.
577+ static bool hasUnavailableConformance (ProtocolConformanceRef conformance) {
578+ // Abstract conformances are never unavailable.
579+ if (!conformance.isConcrete ())
580+ return false ;
581+
582+ // Check whether this conformance is on an unavailable extension.
583+ auto concrete = conformance.getConcrete ();
584+ auto ext = dyn_cast<ExtensionDecl>(concrete->getDeclContext ());
585+ if (ext && AvailableAttr::isUnavailable (ext))
586+ return true ;
587+
588+ // Check the conformances in the substitution map.
589+ auto module = concrete->getDeclContext ()->getParentModule ();
590+ auto subMap = concrete->getSubstitutions (module );
591+ for (auto subConformance : subMap.getConformances ()) {
592+ if (hasUnavailableConformance (subConformance))
593+ return true ;
594+ }
595+
596+ return false ;
597+ }
598+
576599// / Produce a diagnostic for a single instance of a non-Sendable type where
577600// / a Sendable type is required.
578601static bool diagnoseSingleNonSendableType (
@@ -647,8 +670,9 @@ bool swift::diagnoseNonSendableTypes(
647670 if (!proto)
648671 return false ;
649672
673+ // FIXME: More detail for unavailable conformances.
650674 auto conformance = TypeChecker::conformsToProtocol (type, proto, module );
651- if (conformance.isInvalid ()) {
675+ if (conformance.isInvalid () || hasUnavailableConformance (conformance) ) {
652676 return diagnoseSingleNonSendableType (type, module , loc, diagnose);
653677 }
654678
@@ -730,29 +754,6 @@ void swift::diagnoseMissingSendableConformance(
730754}
731755
732756namespace {
733- // / Determine whether there is an unavailable conformance here.
734- static bool hasUnavailableConformance (ProtocolConformanceRef conformance) {
735- // Abstract conformances are never unavailable.
736- if (!conformance.isConcrete ())
737- return false ;
738-
739- // Check whether this conformance is on an unavailable extension.
740- auto concrete = conformance.getConcrete ();
741- auto ext = dyn_cast<ExtensionDecl>(concrete->getDeclContext ());
742- if (ext && AvailableAttr::isUnavailable (ext))
743- return true ;
744-
745- // Check the conformances in the substitution map.
746- auto module = concrete->getDeclContext ()->getParentModule ();
747- auto subMap = concrete->getSubstitutions (module );
748- for (auto subConformance : subMap.getConformances ()) {
749- if (hasUnavailableConformance (subConformance))
750- return true ;
751- }
752-
753- return false ;
754- }
755-
756757 template <typename Visitor>
757758 bool visitInstanceStorage (
758759 NominalTypeDecl *nominal, DeclContext *dc, Visitor &visitor);
0 commit comments