@@ -6763,55 +6763,20 @@ static bool checkSendableInstanceStorage(
67636763 }
67646764 }
67656765
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);
68076767 }
68086768
68096769 // / Handle an enum associated value.
68106770 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);
68126777 diagnoseNonSendableTypes (
6813- elementType , context,
6814- /* inDerivedConformance*/ Type (), element ->getLoc (),
6778+ memberType , context,
6779+ /* inDerivedConformance*/ Type (), member ->getLoc (),
68156780 [&](Type type, DiagnosticBehavior behavior) {
68166781 auto preconcurrency = context.preconcurrencyBehavior (type);
68176782 if (isImplicitSendableCheck (check)) {
@@ -6833,9 +6798,10 @@ static bool checkSendableInstanceStorage(
68336798 if (preconcurrency)
68346799 behavior = preconcurrency.value ();
68356800
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)
68396805 .limitBehaviorWithPreconcurrency (behavior,
68406806 preconcurrency.has_value ());
68416807 return false ;
@@ -6849,6 +6815,7 @@ static bool checkSendableInstanceStorage(
68496815
68506816 return false ;
68516817 }
6818+
68526819 } visitor(nominal, dc, check);
68536820
68546821 return visitor.visit(nominal, dc) || visitor.invalid;
0 commit comments