@@ -6783,55 +6783,20 @@ static bool checkSendableInstanceStorage(
6783
6783
}
6784
6784
}
6785
6785
6786
- // Check that the property type is Sendable.
6787
- SendableCheckContext context (dc, check);
6788
- diagnoseNonSendableTypes (
6789
- propertyType, context,
6790
- /* inDerivedConformance*/ Type (), property->getLoc (),
6791
- [&](Type type, DiagnosticBehavior behavior) {
6792
- auto preconcurrency = context.preconcurrencyBehavior (type);
6793
- if (isImplicitSendableCheck (check)) {
6794
- // If this is for an externally-visible conformance, fail.
6795
- if (check == SendableCheck::ImplicitForExternallyVisible) {
6796
- invalid = true ;
6797
- return true ;
6798
- }
6799
-
6800
- // If we are to ignore this diagnostic, just continue.
6801
- if (behavior == DiagnosticBehavior::Ignore ||
6802
- preconcurrency == DiagnosticBehavior::Ignore)
6803
- return true ;
6804
-
6805
- invalid = true ;
6806
- return true ;
6807
- }
6808
-
6809
- if (preconcurrency)
6810
- behavior = preconcurrency.value ();
6811
-
6812
- property
6813
- ->diagnose (diag::non_concurrent_type_member, propertyType,
6814
- false , property->getName (), nominal)
6815
- .limitBehaviorWithPreconcurrency (behavior,
6816
- preconcurrency.has_value ());
6817
- return false ;
6818
- });
6819
-
6820
- if (invalid) {
6821
- // For implicit checks, bail out early if anything failed.
6822
- if (isImplicitSendableCheck (check))
6823
- return true ;
6824
- }
6825
-
6826
- return false ;
6786
+ return checkSendabilityOfMemberType (property, propertyType);
6827
6787
}
6828
6788
6829
6789
// / Handle an enum associated value.
6830
6790
bool operator ()(EnumElementDecl *element, Type elementType) override {
6831
- SendableCheckContext context (dc, check);
6791
+ return checkSendabilityOfMemberType (element, elementType);
6792
+ }
6793
+
6794
+ private:
6795
+ bool checkSendabilityOfMemberType (ValueDecl *member, Type memberType) {
6796
+ SendableCheckContext context (dc, check);
6832
6797
diagnoseNonSendableTypes (
6833
- elementType , context,
6834
- /* inDerivedConformance*/ Type (), element ->getLoc (),
6798
+ memberType , context,
6799
+ /* inDerivedConformance*/ Type (), member ->getLoc (),
6835
6800
[&](Type type, DiagnosticBehavior behavior) {
6836
6801
auto preconcurrency = context.preconcurrencyBehavior (type);
6837
6802
if (isImplicitSendableCheck (check)) {
@@ -6853,9 +6818,10 @@ static bool checkSendableInstanceStorage(
6853
6818
if (preconcurrency)
6854
6819
behavior = preconcurrency.value ();
6855
6820
6856
- element
6857
- ->diagnose (diag::non_concurrent_type_member, type, true ,
6858
- element->getName (), nominal)
6821
+ member
6822
+ ->diagnose (diag::non_concurrent_type_member, type,
6823
+ isa<EnumElementDecl>(member), member->getName (),
6824
+ nominal)
6859
6825
.limitBehaviorWithPreconcurrency (behavior,
6860
6826
preconcurrency.has_value ());
6861
6827
return false ;
@@ -6869,6 +6835,7 @@ static bool checkSendableInstanceStorage(
6869
6835
6870
6836
return false ;
6871
6837
}
6838
+
6872
6839
} visitor(nominal, dc, check);
6873
6840
6874
6841
return visitor.visit(nominal, dc) || visitor.invalid;
0 commit comments