Skip to content

Commit 84592b8

Browse files
committed
Adopt %kind in Sendable checking diagnostic
Causes minor changes in diagnostic text.
1 parent 3732c75 commit 84592b8

File tree

3 files changed

+28
-32
lines changed

3 files changed

+28
-32
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5282,39 +5282,39 @@ ERROR(isolated_parameter_combined_nonisolated,none,
52825282
(DescriptiveDeclKind))
52835283

52845284
WARNING(non_sendable_param_type,none,
5285-
"non-sendable type %0 %select{passed in call to %4 %2 %3|"
5286-
"exiting %4 context in call to non-isolated %2 %3|"
5287-
"passed in implicitly asynchronous call to %4 %2 %3|"
5288-
"in parameter of the protocol requirement satisfied by %4 %2 %3|"
5289-
"in parameter of superclass method overridden by %4 %2 %3|"
5290-
"in parameter of %4 '@objc' %2 %3}1 cannot cross actor boundary",
5291-
(Type, unsigned, DescriptiveDeclKind, DeclName, ActorIsolation))
5285+
"non-sendable type %0 %select{passed in call to %3 %kind2|"
5286+
"exiting %3 context in call to non-isolated %kind2|"
5287+
"passed in implicitly asynchronous call to %3 %kind2|"
5288+
"in parameter of the protocol requirement satisfied by %3 %kind2|"
5289+
"in parameter of superclass method overridden by %3 %kind2|"
5290+
"in parameter of %3 '@objc' %kind2}1 cannot cross actor boundary",
5291+
(Type, unsigned, const ValueDecl *, ActorIsolation))
52925292
WARNING(non_sendable_call_argument,none,
52935293
"passing argument of non-sendable type %0 %select{into %2 context|"
52945294
"outside of %2 context}1 may introduce data races",
52955295
(Type, bool, ActorIsolation))
52965296
WARNING(non_sendable_result_type,none,
5297-
"non-sendable type %0 returned by %select{call to %4 %2 %3|"
5298-
"call from %4 context to non-isolated %2 %3|"
5299-
"implicitly asynchronous call to %4 %2 %3|"
5300-
"%4 %2 %3 satisfying protocol requirement|"
5301-
"%4 overriding %2 %3|"
5302-
"%4 '@objc' %2 %3}1 cannot cross actor boundary",
5303-
(Type, unsigned, DescriptiveDeclKind, DeclName, ActorIsolation))
5297+
"non-sendable type %0 returned by %select{call to %3 %kind2|"
5298+
"call from %4 context to non-isolated %kind2|"
5299+
"implicitly asynchronous call to %3 %kind2|"
5300+
"%3 %kind2 satisfying protocol requirement|"
5301+
"%3 overriding %kind2|"
5302+
"%3 '@objc' %kind2}1 cannot cross actor boundary",
5303+
(Type, unsigned, const ValueDecl *, ActorIsolation))
53045304
WARNING(non_sendable_call_result_type,none,
53055305
"non-sendable type %0 returned by %select{implicitly asynchronous |}1"
53065306
"call to %2 function cannot cross actor boundary",
53075307
(Type, bool, ActorIsolation))
53085308
WARNING(non_sendable_property_type,none,
53095309
"non-sendable type %0 in %select{"
5310-
"%select{asynchronous access to %5 %1 %2|"
5311-
"asynchronous access from %5 context to non-isolated %1 %2|"
5312-
"implicitly asynchronous access to %5 %1 %2|"
5313-
"conformance of %5 %1 %2 to protocol requirement|"
5314-
"%5 overriding %1 %2|"
5315-
"%5 '@objc' %1 %2}4|captured local %1 %2}3 cannot "
5316-
"cross %select{actor|task}3 boundary",
5317-
(Type, DescriptiveDeclKind, DeclName, bool, unsigned, ActorIsolation))
5310+
"%select{asynchronous access to %4 %kind1|"
5311+
"asynchronous access from %4 context to non-isolated %kind1|"
5312+
"implicitly asynchronous access to %4 %kind1|"
5313+
"conformance of %4 %kind1 to protocol requirement|"
5314+
"%4 overriding %kind1|"
5315+
"%4 '@objc' %kind1}3|captured local %1}2 cannot "
5316+
"cross %select{actor|task}2 boundary",
5317+
(Type, const ValueDecl *, bool, unsigned, ActorIsolation))
53185318
WARNING(non_sendable_keypath_capture,none,
53195319
"cannot form key path that captures non-sendable type %0",
53205320
(Type))

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,8 +1025,7 @@ bool swift::diagnoseNonSendableTypesInReference(
10251025
if (diagnoseNonSendableTypes(
10261026
paramType, fromDC, refLoc, diagnoseLoc.isInvalid() ? refLoc : diagnoseLoc,
10271027
diag::non_sendable_param_type,
1028-
(unsigned)refKind, function->getDescriptiveKind(),
1029-
function->getName(), getActorIsolation()))
1028+
(unsigned)refKind, function, getActorIsolation()))
10301029
return true;
10311030
}
10321031
}
@@ -1039,8 +1038,7 @@ bool swift::diagnoseNonSendableTypesInReference(
10391038
if (diagnoseNonSendableTypes(
10401039
resultType, fromDC, refLoc, diagnoseLoc.isInvalid() ? refLoc : diagnoseLoc,
10411040
diag::non_sendable_result_type,
1042-
(unsigned)refKind, func->getDescriptiveKind(), func->getName(),
1043-
getActorIsolation()))
1041+
(unsigned)refKind, func, getActorIsolation()))
10441042
return true;
10451043
}
10461044
}
@@ -1055,7 +1053,7 @@ bool swift::diagnoseNonSendableTypesInReference(
10551053
if (diagnoseNonSendableTypes(
10561054
propertyType, fromDC, refLoc,
10571055
diag::non_sendable_property_type,
1058-
var->getDescriptiveKind(), var->getName(),
1056+
var,
10591057
var->isLocalCapture(),
10601058
(unsigned)refKind,
10611059
getActorIsolation()))
@@ -1070,8 +1068,7 @@ bool swift::diagnoseNonSendableTypesInReference(
10701068
if (diagnoseNonSendableTypes(
10711069
paramType, fromDC, refLoc, diagnoseLoc.isInvalid() ? refLoc : diagnoseLoc,
10721070
diag::non_sendable_param_type,
1073-
(unsigned)refKind, subscript->getDescriptiveKind(),
1074-
subscript->getName(), getActorIsolation()))
1071+
(unsigned)refKind, subscript, getActorIsolation()))
10751072
return true;
10761073
}
10771074
}
@@ -1082,8 +1079,7 @@ bool swift::diagnoseNonSendableTypesInReference(
10821079
if (diagnoseNonSendableTypes(
10831080
resultType, fromDC, refLoc, diagnoseLoc.isInvalid() ? refLoc : diagnoseLoc,
10841081
diag::non_sendable_result_type,
1085-
(unsigned)refKind, subscript->getDescriptiveKind(),
1086-
subscript->getName(), getActorIsolation()))
1082+
(unsigned)refKind, subscript, getActorIsolation()))
10871083
return true;
10881084
}
10891085

test/Concurrency/sendable_checking.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ class SubWUnsafeSubscript : SuperWUnsafeSubscript {
210210
override nonisolated subscript<T>(x : T) -> Int {
211211
get async {
212212
// expected-warning@-2{{non-sendable type 'T' in parameter of superclass method overridden by nonisolated subscript 'subscript(_:)' cannot cross actor boundary}}
213-
// expected-warning@-2{{non-sendable type 'T' in parameter of superclass method overridden by nonisolated getter '_' cannot cross actor boundary}}
213+
// expected-warning@-2{{non-sendable type 'T' in parameter of superclass method overridden by nonisolated getter for subscript 'subscript(_:)' cannot cross actor boundary}}
214214
// there really shouldn't be two warnings produced here, see rdar://110846040 (Sendable diagnostics reported twice for subscript getters)
215215
return 0
216216
}

0 commit comments

Comments
 (0)