@@ -736,7 +736,7 @@ static bool shouldDiagnoseExistingDataRaces(const DeclContext *dc) {
736736// / Determine the default diagnostic behavior for this language mode.
737737static DiagnosticBehavior defaultSendableDiagnosticBehavior (
738738 const LangOptions &langOpts) {
739- // Prior to Swift 6, all Sendable-related diagnostics are warnings.
739+ // Prior to Swift 6, all Sendable-related diagnostics are warnings at most .
740740 if (!langOpts.isSwiftVersionAtLeast (6 ))
741741 return DiagnosticBehavior::Warning;
742742
@@ -768,6 +768,30 @@ DiagnosticBehavior SendableCheckContext::defaultDiagnosticBehavior() const {
768768 return defaultSendableDiagnosticBehavior (fromDC->getASTContext ().LangOpts );
769769}
770770
771+ DiagnosticBehavior
772+ SendableCheckContext::implicitSendableDiagnosticBehavior () const {
773+ switch (fromDC->getASTContext ().LangOpts .StrictConcurrencyLevel ) {
774+ case StrictConcurrency::Limited:
775+ // Limited checking only diagnoses implicit Sendable within contexts that
776+ // have adopted concurrency.
777+ if (shouldDiagnoseExistingDataRaces (fromDC))
778+ return DiagnosticBehavior::Warning;
779+
780+ LLVM_FALLTHROUGH;
781+
782+ case StrictConcurrency::Off:
783+ // Explicit Sendable conformances always diagnose, even when strict
784+ // strict checking is disabled.
785+ if (isExplicitSendableConformance ())
786+ return DiagnosticBehavior::Warning;
787+
788+ return DiagnosticBehavior::Ignore;
789+
790+ case StrictConcurrency::On:
791+ return defaultDiagnosticBehavior ();
792+ }
793+ }
794+
771795// / Determine whether the given nominal type has an explicit Sendable
772796// / conformance (regardless of its availability).
773797static bool hasExplicitSendableConformance (NominalTypeDecl *nominal,
@@ -862,10 +886,10 @@ DiagnosticBehavior SendableCheckContext::diagnosticBehavior(
862886 : DiagnosticBehavior::Ignore;
863887 }
864888
865- auto defaultBehavior = defaultDiagnosticBehavior ();
889+ DiagnosticBehavior defaultBehavior = implicitSendableDiagnosticBehavior ();
866890
867891 // If we are checking an implicit Sendable conformance, don't suppress
868- // diagnostics for declarations in the same module. We want them so make
892+ // diagnostics for declarations in the same module. We want them to make
869893 // enclosing inferred types non-Sendable.
870894 if (defaultBehavior == DiagnosticBehavior::Ignore &&
871895 nominal->getParentSourceFile () &&
@@ -883,7 +907,7 @@ bool swift::diagnoseSendabilityErrorBasedOn(
883907 if (nominal) {
884908 behavior = fromContext.diagnosticBehavior (nominal);
885909 } else {
886- behavior = fromContext.defaultDiagnosticBehavior ();
910+ behavior = fromContext.implicitSendableDiagnosticBehavior ();
887911 }
888912
889913 bool wasSuppressed = diagnose (behavior);
0 commit comments