@@ -902,27 +902,30 @@ static bool isConcurrentValueType(const DeclContext *dc, Type type) {
902
902
903
903
static bool diagnoseNonConcurrentParameter (
904
904
SourceLoc loc, ConcurrentReferenceKind refKind, ConcreteDeclRef declRef,
905
- ParamDecl *param, Type paramType) {
905
+ ParamDecl *param, Type paramType, DiagnosticBehavior behavior ) {
906
906
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);
908
909
return false ;
909
910
}
910
911
911
912
static bool diagnoseNonConcurrentResult (
912
913
SourceLoc loc, ConcurrentReferenceKind refKind, ConcreteDeclRef declRef,
913
- Type resultType) {
914
+ Type resultType, DiagnosticBehavior behavior ) {
914
915
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);
916
918
return false ;
917
919
}
918
920
919
921
static bool diagnoseNonConcurrentProperty (
920
922
SourceLoc loc, ConcurrentReferenceKind refKind, VarDecl *var,
921
- Type propertyType) {
923
+ Type propertyType, DiagnosticBehavior behavior ) {
922
924
ASTContext &ctx = var->getASTContext ();
923
925
ctx.Diags .diagnose (loc, diag::non_concurrent_property_type,
924
926
var->getDescriptiveKind (), var->getName (),
925
- propertyType, var->isLocalCapture ());
927
+ propertyType, var->isLocalCapture ())
928
+ .limitBehavior (behavior);
926
929
return false ;
927
930
}
928
931
@@ -935,7 +938,7 @@ static bool shouldDiagnoseNonConcurrentValueViolations(
935
938
936
939
bool swift::diagnoseNonConcurrentTypesInReference (
937
940
ConcreteDeclRef declRef, const DeclContext *dc, SourceLoc loc,
938
- ConcurrentReferenceKind refKind) {
941
+ ConcurrentReferenceKind refKind, DiagnosticBehavior behavior ) {
939
942
// Bail out immediately if we aren't supposed to do this checking.
940
943
if (!shouldDiagnoseNonConcurrentValueViolations (dc->getASTContext ().LangOpts ))
941
944
return false ;
@@ -947,15 +950,16 @@ bool swift::diagnoseNonConcurrentTypesInReference(
947
950
Type paramType = param->getInterfaceType ().subst (subs);
948
951
if (!isConcurrentValueType (dc, paramType)) {
949
952
return diagnoseNonConcurrentParameter (
950
- loc, refKind, declRef, param, paramType);
953
+ loc, refKind, declRef, param, paramType, behavior );
951
954
}
952
955
}
953
956
954
957
// Check the result type of a function.
955
958
if (auto func = dyn_cast<FuncDecl>(function)) {
956
959
Type resultType = func->getResultInterfaceType ().subst (subs);
957
960
if (!isConcurrentValueType (dc, resultType)) {
958
- return diagnoseNonConcurrentResult (loc, refKind, declRef, resultType);
961
+ return diagnoseNonConcurrentResult (loc, refKind, declRef, resultType,
962
+ behavior);
959
963
}
960
964
}
961
965
@@ -967,7 +971,8 @@ bool swift::diagnoseNonConcurrentTypesInReference(
967
971
? var->getType ()
968
972
: var->getValueInterfaceType ().subst (subs);
969
973
if (!isConcurrentValueType (dc, propertyType)) {
970
- return diagnoseNonConcurrentProperty (loc, refKind, var, propertyType);
974
+ return diagnoseNonConcurrentProperty (loc, refKind, var, propertyType,
975
+ behavior);
971
976
}
972
977
}
973
978
@@ -976,14 +981,15 @@ bool swift::diagnoseNonConcurrentTypesInReference(
976
981
Type paramType = param->getInterfaceType ().subst (subs);
977
982
if (!isConcurrentValueType (dc, paramType)) {
978
983
return diagnoseNonConcurrentParameter (
979
- loc, refKind, declRef, param, paramType);
984
+ loc, refKind, declRef, param, paramType, behavior );
980
985
}
981
986
}
982
987
983
988
// Check the element type of a subscript.
984
989
Type resultType = subscript->getElementInterfaceType ().subst (subs);
985
990
if (!isConcurrentValueType (dc, resultType)) {
986
- return diagnoseNonConcurrentResult (loc, refKind, declRef, resultType);
991
+ return diagnoseNonConcurrentResult (loc, refKind, declRef, resultType,
992
+ behavior);
987
993
}
988
994
989
995
return false ;
0 commit comments