@@ -6763,55 +6763,20 @@ static bool checkSendableInstanceStorage(
6763
6763
}
6764
6764
}
6765
6765
6766
- // Check that the property type is Sendable.
6767
- SendableCheckContext context (dc, check);
6768
- diagnoseNonSendableTypes (
6769
- propertyType, context,
6770
- /* inDerivedConformance*/ Type (), property->getLoc (),
6771
- [&](Type type, DiagnosticBehavior behavior) {
6772
- auto preconcurrency = context.preconcurrencyBehavior (type);
6773
- if (isImplicitSendableCheck (check)) {
6774
- // If this is for an externally-visible conformance, fail.
6775
- if (check == SendableCheck::ImplicitForExternallyVisible) {
6776
- invalid = true ;
6777
- return true ;
6778
- }
6779
-
6780
- // If we are to ignore this diagnostic, just continue.
6781
- if (behavior == DiagnosticBehavior::Ignore ||
6782
- preconcurrency == DiagnosticBehavior::Ignore)
6783
- return true ;
6784
-
6785
- invalid = true ;
6786
- return true ;
6787
- }
6788
-
6789
- if (preconcurrency)
6790
- behavior = preconcurrency.value ();
6791
-
6792
- property
6793
- ->diagnose (diag::non_concurrent_type_member, propertyType,
6794
- false , property->getName (), nominal)
6795
- .limitBehaviorWithPreconcurrency (behavior,
6796
- preconcurrency.has_value ());
6797
- return false ;
6798
- });
6799
-
6800
- if (invalid) {
6801
- // For implicit checks, bail out early if anything failed.
6802
- if (isImplicitSendableCheck (check))
6803
- return true ;
6804
- }
6805
-
6806
- return false ;
6766
+ return checkSendabilityOfMemberType (property, propertyType);
6807
6767
}
6808
6768
6809
6769
// / Handle an enum associated value.
6810
6770
bool operator ()(EnumElementDecl *element, Type elementType) override {
6811
- SendableCheckContext context (dc, check);
6771
+ return checkSendabilityOfMemberType (element, elementType);
6772
+ }
6773
+
6774
+ private:
6775
+ bool checkSendabilityOfMemberType (ValueDecl *member, Type memberType) {
6776
+ SendableCheckContext context (dc, check);
6812
6777
diagnoseNonSendableTypes (
6813
- elementType , context,
6814
- /* inDerivedConformance*/ Type (), element ->getLoc (),
6778
+ memberType , context,
6779
+ /* inDerivedConformance*/ Type (), member ->getLoc (),
6815
6780
[&](Type type, DiagnosticBehavior behavior) {
6816
6781
auto preconcurrency = context.preconcurrencyBehavior (type);
6817
6782
if (isImplicitSendableCheck (check)) {
@@ -6833,9 +6798,10 @@ static bool checkSendableInstanceStorage(
6833
6798
if (preconcurrency)
6834
6799
behavior = preconcurrency.value ();
6835
6800
6836
- element
6837
- ->diagnose (diag::non_concurrent_type_member, type, true ,
6838
- element->getName (), nominal)
6801
+ member
6802
+ ->diagnose (diag::non_concurrent_type_member, type,
6803
+ isa<EnumElementDecl>(member), member->getName (),
6804
+ nominal)
6839
6805
.limitBehaviorWithPreconcurrency (behavior,
6840
6806
preconcurrency.has_value ());
6841
6807
return false ;
@@ -6849,6 +6815,7 @@ static bool checkSendableInstanceStorage(
6849
6815
6850
6816
return false ;
6851
6817
}
6818
+
6852
6819
} visitor(nominal, dc, check);
6853
6820
6854
6821
return visitor.visit(nominal, dc) || visitor.invalid;
0 commit comments