@@ -714,7 +714,6 @@ DiagnosticBehavior SendableCheckContext::diagnosticBehavior(
714
714
// Determine whether the type was explicitly non-Sendable.
715
715
auto nominalModule = nominal->getParentModule ();
716
716
bool isExplicitlyNonSendable = nominalModule->isConcurrencyChecked () ||
717
- isExplicitSendableConformance () ||
718
717
hasExplicitSendableConformance (nominal);
719
718
720
719
// Determine whether this nominal type is visible via a @preconcurrency
@@ -723,7 +722,7 @@ DiagnosticBehavior SendableCheckContext::diagnosticBehavior(
723
722
724
723
// When the type is explicitly non-Sendable...
725
724
if (isExplicitlyNonSendable) {
726
- // @preconcurrency imports downgrade the diagnostic to a warning.
725
+ // @preconcurrency imports downgrade the diagnostic to a warning in Swift 6,
727
726
if (import && import ->options .contains (ImportFlags::Preconcurrency)) {
728
727
// FIXME: Note that this @preconcurrency import was "used".
729
728
return DiagnosticBehavior::Warning;
@@ -743,7 +742,17 @@ DiagnosticBehavior SendableCheckContext::diagnosticBehavior(
743
742
: DiagnosticBehavior::Ignore;
744
743
}
745
744
746
- return defaultDiagnosticBehavior ();
745
+ auto defaultBehavior = defaultDiagnosticBehavior ();
746
+
747
+ // If we are checking an implicit Sendable conformance, don't suppress
748
+ // diagnostics for declarations in the same module. We want them so make
749
+ // enclosing inferred types non-Sendable.
750
+ if (defaultBehavior == DiagnosticBehavior::Ignore &&
751
+ nominal->getParentSourceFile () &&
752
+ conformanceCheck && *conformanceCheck == SendableCheck::Implicit)
753
+ return DiagnosticBehavior::Warning;
754
+
755
+ return defaultBehavior;
747
756
}
748
757
749
758
// / Produce a diagnostic for a single instance of a non-Sendable type where
@@ -3871,8 +3880,10 @@ static bool checkSendableInstanceStorage(
3871
3880
bool operator ()(VarDecl *property, Type propertyType) {
3872
3881
// Classes with mutable properties are not Sendable.
3873
3882
if (property->supportsMutation () && isa<ClassDecl>(nominal)) {
3874
- if (check == SendableCheck::Implicit)
3883
+ if (check == SendableCheck::Implicit) {
3884
+ invalid = true ;
3875
3885
return true ;
3886
+ }
3876
3887
3877
3888
auto behavior = SendableCheckContext (
3878
3889
dc, check).defaultDiagnosticBehavior ();
@@ -3891,6 +3902,10 @@ static bool checkSendableInstanceStorage(
3891
3902
propertyType, SendableCheckContext (dc, check), property->getLoc (),
3892
3903
[&](Type type, DiagnosticBehavior behavior) {
3893
3904
if (check == SendableCheck::Implicit) {
3905
+ // If we are to ignore this diagnose, just continue.
3906
+ if (behavior == DiagnosticBehavior::Ignore)
3907
+ return false ;
3908
+
3894
3909
invalid = true ;
3895
3910
return true ;
3896
3911
}
@@ -3918,6 +3933,10 @@ static bool checkSendableInstanceStorage(
3918
3933
elementType, SendableCheckContext (dc, check), element->getLoc (),
3919
3934
[&](Type type, DiagnosticBehavior behavior) {
3920
3935
if (check == SendableCheck::Implicit) {
3936
+ // If we are to ignore this diagnose, just continue.
3937
+ if (behavior == DiagnosticBehavior::Ignore)
3938
+ return false ;
3939
+
3921
3940
invalid = true ;
3922
3941
return true ;
3923
3942
}
0 commit comments