@@ -6783,55 +6783,20 @@ static bool checkSendableInstanceStorage(
67836783 }
67846784 }
67856785
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);
68276787 }
68286788
68296789 // / Handle an enum associated value.
68306790 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);
68326797 diagnoseNonSendableTypes (
6833- elementType , context,
6834- /* inDerivedConformance*/ Type (), element ->getLoc (),
6798+ memberType , context,
6799+ /* inDerivedConformance*/ Type (), member ->getLoc (),
68356800 [&](Type type, DiagnosticBehavior behavior) {
68366801 auto preconcurrency = context.preconcurrencyBehavior (type);
68376802 if (isImplicitSendableCheck (check)) {
@@ -6853,9 +6818,10 @@ static bool checkSendableInstanceStorage(
68536818 if (preconcurrency)
68546819 behavior = preconcurrency.value ();
68556820
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)
68596825 .limitBehaviorWithPreconcurrency (behavior,
68606826 preconcurrency.has_value ());
68616827 return false ;
@@ -6869,6 +6835,7 @@ static bool checkSendableInstanceStorage(
68696835
68706836 return false ;
68716837 }
6838+
68726839 } visitor(nominal, dc, check);
68736840
68746841 return visitor.visit(nominal, dc) || visitor.invalid;
0 commit comments