@@ -6768,11 +6768,16 @@ static bool checkSendableInstanceStorage(
6768
6768
if (property->supportsMutation () && isolation.isUnspecified ()) {
6769
6769
auto behavior =
6770
6770
SendableCheckContext (dc, check).defaultDiagnosticBehavior ();
6771
+ // If Sendable came from a `@preconcurrency` protocol the error
6772
+ // should be downgraded even with strict concurrency checking to
6773
+ // allow clients time to address the new requirement.
6774
+ auto preconcurrency =
6775
+ check == SendableCheck::ImpliedByPreconcurrencyProtocol;
6771
6776
if (behavior != DiagnosticBehavior::Ignore) {
6772
6777
property
6773
6778
->diagnose (diag::concurrent_value_class_mutable_property,
6774
6779
property->getName (), nominal)
6775
- .limitBehaviorUntilSwiftVersion (behavior, 6 );
6780
+ .limitBehaviorWithPreconcurrency (behavior, preconcurrency );
6776
6781
}
6777
6782
invalid = invalid || (behavior == DiagnosticBehavior::Unspecified);
6778
6783
return true ;
@@ -6798,7 +6803,7 @@ static bool checkSendableInstanceStorage(
6798
6803
memberType, context,
6799
6804
/* inDerivedConformance*/ Type (), member->getLoc (),
6800
6805
[&](Type type, DiagnosticBehavior behavior) {
6801
- auto preconcurrency = context.preconcurrencyBehavior (type);
6806
+ auto preconcurrencyBehavior = context.preconcurrencyBehavior (type);
6802
6807
if (isImplicitSendableCheck (check)) {
6803
6808
// If this is for an externally-visible conformance, fail.
6804
6809
if (check == SendableCheck::ImplicitForExternallyVisible) {
@@ -6808,22 +6813,29 @@ static bool checkSendableInstanceStorage(
6808
6813
6809
6814
// If we are to ignore this diagnostic, just continue.
6810
6815
if (behavior == DiagnosticBehavior::Ignore ||
6811
- preconcurrency == DiagnosticBehavior::Ignore)
6816
+ preconcurrencyBehavior == DiagnosticBehavior::Ignore)
6812
6817
return true ;
6813
6818
6814
6819
invalid = true ;
6815
6820
return true ;
6816
6821
}
6817
6822
6818
- if (preconcurrency)
6819
- behavior = preconcurrency.value ();
6823
+ // If Sendable came from a `@preconcurrency` protocol the error
6824
+ // should be downgraded even with strict concurrency checking to
6825
+ // allow clients time to address the new requirement.
6826
+ bool fromPreconcurrencyConformance =
6827
+ check == SendableCheck::ImpliedByPreconcurrencyProtocol;
6828
+
6829
+ if (preconcurrencyBehavior)
6830
+ behavior = preconcurrencyBehavior.value ();
6820
6831
6821
6832
member
6822
6833
->diagnose (diag::non_concurrent_type_member, type,
6823
6834
isa<EnumElementDecl>(member), member->getName (),
6824
6835
nominal)
6825
- .limitBehaviorWithPreconcurrency (behavior,
6826
- preconcurrency.has_value ());
6836
+ .limitBehaviorWithPreconcurrency (
6837
+ behavior, fromPreconcurrencyConformance ||
6838
+ preconcurrencyBehavior.has_value ());
6827
6839
return false ;
6828
6840
});
6829
6841
0 commit comments