@@ -902,27 +902,30 @@ static bool isConcurrentValueType(const DeclContext *dc, Type type) {
902902
903903static bool diagnoseNonConcurrentParameter (
904904 SourceLoc loc, ConcurrentReferenceKind refKind, ConcreteDeclRef declRef,
905- ParamDecl *param, Type paramType) {
905+ ParamDecl *param, Type paramType, DiagnosticBehavior behavior ) {
906906 ASTContext &ctx = declRef.getDecl ()->getASTContext ();
907- ctx.Diags .diagnose (loc, diag::non_concurrent_param_type, paramType);
907+ ctx.Diags .diagnose (loc, diag::non_concurrent_param_type, paramType)
908+ .limitBehavior (behavior);
908909 return false ;
909910}
910911
911912static bool diagnoseNonConcurrentResult (
912913 SourceLoc loc, ConcurrentReferenceKind refKind, ConcreteDeclRef declRef,
913- Type resultType) {
914+ Type resultType, DiagnosticBehavior behavior ) {
914915 ASTContext &ctx = declRef.getDecl ()->getASTContext ();
915- ctx.Diags .diagnose (loc, diag::non_concurrent_result_type, resultType);
916+ ctx.Diags .diagnose (loc, diag::non_concurrent_result_type, resultType)
917+ .limitBehavior (behavior);
916918 return false ;
917919}
918920
919921static bool diagnoseNonConcurrentProperty (
920922 SourceLoc loc, ConcurrentReferenceKind refKind, VarDecl *var,
921- Type propertyType) {
923+ Type propertyType, DiagnosticBehavior behavior ) {
922924 ASTContext &ctx = var->getASTContext ();
923925 ctx.Diags .diagnose (loc, diag::non_concurrent_property_type,
924926 var->getDescriptiveKind (), var->getName (),
925- propertyType, var->isLocalCapture ());
927+ propertyType, var->isLocalCapture ())
928+ .limitBehavior (behavior);
926929 return false ;
927930}
928931
@@ -935,7 +938,7 @@ static bool shouldDiagnoseNonConcurrentValueViolations(
935938
936939bool swift::diagnoseNonConcurrentTypesInReference (
937940 ConcreteDeclRef declRef, const DeclContext *dc, SourceLoc loc,
938- ConcurrentReferenceKind refKind) {
941+ ConcurrentReferenceKind refKind, DiagnosticBehavior behavior ) {
939942 // Bail out immediately if we aren't supposed to do this checking.
940943 if (!shouldDiagnoseNonConcurrentValueViolations (dc->getASTContext ().LangOpts ))
941944 return false ;
@@ -947,15 +950,16 @@ bool swift::diagnoseNonConcurrentTypesInReference(
947950 Type paramType = param->getInterfaceType ().subst (subs);
948951 if (!isConcurrentValueType (dc, paramType)) {
949952 return diagnoseNonConcurrentParameter (
950- loc, refKind, declRef, param, paramType);
953+ loc, refKind, declRef, param, paramType, behavior );
951954 }
952955 }
953956
954957 // Check the result type of a function.
955958 if (auto func = dyn_cast<FuncDecl>(function)) {
956959 Type resultType = func->getResultInterfaceType ().subst (subs);
957960 if (!isConcurrentValueType (dc, resultType)) {
958- return diagnoseNonConcurrentResult (loc, refKind, declRef, resultType);
961+ return diagnoseNonConcurrentResult (loc, refKind, declRef, resultType,
962+ behavior);
959963 }
960964 }
961965
@@ -967,7 +971,8 @@ bool swift::diagnoseNonConcurrentTypesInReference(
967971 ? var->getType ()
968972 : var->getValueInterfaceType ().subst (subs);
969973 if (!isConcurrentValueType (dc, propertyType)) {
970- return diagnoseNonConcurrentProperty (loc, refKind, var, propertyType);
974+ return diagnoseNonConcurrentProperty (loc, refKind, var, propertyType,
975+ behavior);
971976 }
972977 }
973978
@@ -976,14 +981,15 @@ bool swift::diagnoseNonConcurrentTypesInReference(
976981 Type paramType = param->getInterfaceType ().subst (subs);
977982 if (!isConcurrentValueType (dc, paramType)) {
978983 return diagnoseNonConcurrentParameter (
979- loc, refKind, declRef, param, paramType);
984+ loc, refKind, declRef, param, paramType, behavior );
980985 }
981986 }
982987
983988 // Check the element type of a subscript.
984989 Type resultType = subscript->getElementInterfaceType ().subst (subs);
985990 if (!isConcurrentValueType (dc, resultType)) {
986- return diagnoseNonConcurrentResult (loc, refKind, declRef, resultType);
991+ return diagnoseNonConcurrentResult (loc, refKind, declRef, resultType,
992+ behavior);
987993 }
988994
989995 return false ;
0 commit comments