@@ -573,6 +573,29 @@ static void addSendableFixIt(
573
573
}
574
574
}
575
575
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
+
576
599
// / Produce a diagnostic for a single instance of a non-Sendable type where
577
600
// / a Sendable type is required.
578
601
static bool diagnoseSingleNonSendableType (
@@ -647,8 +670,9 @@ bool swift::diagnoseNonSendableTypes(
647
670
if (!proto)
648
671
return false ;
649
672
673
+ // FIXME: More detail for unavailable conformances.
650
674
auto conformance = TypeChecker::conformsToProtocol (type, proto, module );
651
- if (conformance.isInvalid ()) {
675
+ if (conformance.isInvalid () || hasUnavailableConformance (conformance) ) {
652
676
return diagnoseSingleNonSendableType (type, module , loc, diagnose);
653
677
}
654
678
@@ -730,29 +754,6 @@ void swift::diagnoseMissingSendableConformance(
730
754
}
731
755
732
756
namespace {
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
-
756
757
template <typename Visitor>
757
758
bool visitInstanceStorage (
758
759
NominalTypeDecl *nominal, DeclContext *dc, Visitor &visitor);
0 commit comments