@@ -616,7 +616,7 @@ static bool shouldDiagnoseExistingDataRaces(const DeclContext *dc) {
616616// / Determine the default diagnostic behavior for this language mode.
617617static DiagnosticBehavior defaultSendableDiagnosticBehavior (
618618 const LangOptions &langOpts) {
619- // Prior to Swift 6, all Sendable-related diagnostics are warnings.
619+ // Prior to Swift 6, all Sendable-related diagnostics are warnings at most .
620620 if (!langOpts.isSwiftVersionAtLeast (6 ))
621621 return DiagnosticBehavior::Warning;
622622
@@ -648,6 +648,30 @@ DiagnosticBehavior SendableCheckContext::defaultDiagnosticBehavior() const {
648648 return defaultSendableDiagnosticBehavior (fromDC->getASTContext ().LangOpts );
649649}
650650
651+ DiagnosticBehavior
652+ SendableCheckContext::implicitSendableDiagnosticBehavior () const {
653+ switch (fromDC->getASTContext ().LangOpts .StrictConcurrencyLevel ) {
654+ case StrictConcurrency::Limited:
655+ // Limited checking only diagnoses implicit Sendable within contexts that
656+ // have adopted concurrency.
657+ if (shouldDiagnoseExistingDataRaces (fromDC))
658+ return DiagnosticBehavior::Warning;
659+
660+ LLVM_FALLTHROUGH;
661+
662+ case StrictConcurrency::Off:
663+ // Explicit Sendable conformances always diagnose, even when strict
664+ // strict checking is disabled.
665+ if (isExplicitSendableConformance ())
666+ return DiagnosticBehavior::Warning;
667+
668+ return DiagnosticBehavior::Ignore;
669+
670+ case StrictConcurrency::On:
671+ return defaultDiagnosticBehavior ();
672+ }
673+ }
674+
651675// / Determine whether the given nominal type has an explicit Sendable
652676// / conformance (regardless of its availability).
653677static bool hasExplicitSendableConformance (NominalTypeDecl *nominal,
@@ -742,10 +766,10 @@ DiagnosticBehavior SendableCheckContext::diagnosticBehavior(
742766 : DiagnosticBehavior::Ignore;
743767 }
744768
745- auto defaultBehavior = defaultDiagnosticBehavior ();
769+ DiagnosticBehavior defaultBehavior = implicitSendableDiagnosticBehavior ();
746770
747771 // If we are checking an implicit Sendable conformance, don't suppress
748- // diagnostics for declarations in the same module. We want them so make
772+ // diagnostics for declarations in the same module. We want them to make
749773 // enclosing inferred types non-Sendable.
750774 if (defaultBehavior == DiagnosticBehavior::Ignore &&
751775 nominal->getParentSourceFile () &&
@@ -763,7 +787,7 @@ bool swift::diagnoseSendabilityErrorBasedOn(
763787 if (nominal) {
764788 behavior = fromContext.diagnosticBehavior (nominal);
765789 } else {
766- behavior = fromContext.defaultDiagnosticBehavior ();
790+ behavior = fromContext.implicitSendableDiagnosticBehavior ();
767791 }
768792
769793 bool wasSuppressed = diagnose (behavior);
0 commit comments