@@ -719,7 +719,6 @@ DiagnosticBehavior SendableCheckContext::diagnosticBehavior(
719
719
// Determine whether the type was explicitly non-Sendable.
720
720
auto nominalModule = nominal->getParentModule ();
721
721
bool isExplicitlyNonSendable = nominalModule->isConcurrencyChecked () ||
722
- isExplicitSendableConformance () ||
723
722
hasExplicitSendableConformance (nominal);
724
723
725
724
// Determine whether this nominal type is visible via a @preconcurrency
@@ -728,7 +727,7 @@ DiagnosticBehavior SendableCheckContext::diagnosticBehavior(
728
727
729
728
// When the type is explicitly non-Sendable...
730
729
if (isExplicitlyNonSendable) {
731
- // @preconcurrency imports downgrade the diagnostic to a warning.
730
+ // @preconcurrency imports downgrade the diagnostic to a warning in Swift 6,
732
731
if (import && import ->options .contains (ImportFlags::Preconcurrency)) {
733
732
// FIXME: Note that this @preconcurrency import was "used".
734
733
return DiagnosticBehavior::Warning;
@@ -748,7 +747,17 @@ DiagnosticBehavior SendableCheckContext::diagnosticBehavior(
748
747
: DiagnosticBehavior::Ignore;
749
748
}
750
749
751
- return defaultDiagnosticBehavior ();
750
+ auto defaultBehavior = defaultDiagnosticBehavior ();
751
+
752
+ // If we are checking an implicit Sendable conformance, don't suppress
753
+ // diagnostics for declarations in the same module. We want them so make
754
+ // enclosing inferred types non-Sendable.
755
+ if (defaultBehavior == DiagnosticBehavior::Ignore &&
756
+ nominal->getParentSourceFile () &&
757
+ conformanceCheck && *conformanceCheck == SendableCheck::Implicit)
758
+ return DiagnosticBehavior::Warning;
759
+
760
+ return defaultBehavior;
752
761
}
753
762
754
763
// / Produce a diagnostic for a single instance of a non-Sendable type where
@@ -3890,8 +3899,10 @@ static bool checkSendableInstanceStorage(
3890
3899
bool operator ()(VarDecl *property, Type propertyType) {
3891
3900
// Classes with mutable properties are not Sendable.
3892
3901
if (property->supportsMutation () && isa<ClassDecl>(nominal)) {
3893
- if (check == SendableCheck::Implicit)
3902
+ if (check == SendableCheck::Implicit) {
3903
+ invalid = true ;
3894
3904
return true ;
3905
+ }
3895
3906
3896
3907
auto behavior = SendableCheckContext (
3897
3908
dc, check).defaultDiagnosticBehavior ();
@@ -3910,6 +3921,10 @@ static bool checkSendableInstanceStorage(
3910
3921
propertyType, SendableCheckContext (dc, check), property->getLoc (),
3911
3922
[&](Type type, DiagnosticBehavior behavior) {
3912
3923
if (check == SendableCheck::Implicit) {
3924
+ // If we are to ignore this diagnose, just continue.
3925
+ if (behavior == DiagnosticBehavior::Ignore)
3926
+ return false ;
3927
+
3913
3928
invalid = true ;
3914
3929
return true ;
3915
3930
}
@@ -3937,6 +3952,10 @@ static bool checkSendableInstanceStorage(
3937
3952
elementType, SendableCheckContext (dc, check), element->getLoc (),
3938
3953
[&](Type type, DiagnosticBehavior behavior) {
3939
3954
if (check == SendableCheck::Implicit) {
3955
+ // If we are to ignore this diagnose, just continue.
3956
+ if (behavior == DiagnosticBehavior::Ignore)
3957
+ return false ;
3958
+
3940
3959
invalid = true ;
3941
3960
return true ;
3942
3961
}
0 commit comments