Skip to content

Commit 3495c61

Browse files
committed
[Diagnostics] Use contains instead of has when non-Sendable type appears inside of a member type
1 parent 6d45229 commit 3495c61

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5923,8 +5923,8 @@ ERROR(non_sendable_keypath_capture,none,
59235923
(Type))
59245924
ERROR(non_concurrent_type_member,none,
59255925
"%select{stored property %2|associated value %2}1 of "
5926-
"'Sendable'-conforming %kind3 has non-Sendable type %0",
5927-
(Type, bool, DeclName, const ValueDecl *))
5926+
"'Sendable'-conforming %kind3 %select{contains|has}4 non-Sendable type %0",
5927+
(Type, bool, DeclName, const ValueDecl *, bool))
59285928
ERROR(concurrent_value_class_mutable_property,none,
59295929
"stored property %0 of 'Sendable'-conforming %kind1 is mutable",
59305930
(DeclName, const ValueDecl *))

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6812,7 +6812,7 @@ static bool checkSendableInstanceStorage(
68126812
member
68136813
->diagnose(diag::non_concurrent_type_member, type,
68146814
isa<EnumElementDecl>(member), member->getName(),
6815-
nominal)
6815+
nominal, type->isEqual(memberType))
68166816
.limitBehaviorWithPreconcurrency(
68176817
behavior, fromPreconcurrencyConformance ||
68186818
preconcurrencyBehavior.has_value());

test/Concurrency/concurrent_value_checking.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ enum E2<T> {
337337
extension E2: Sendable where T: Sendable { }
338338

339339
final class C1: Sendable {
340-
let nc: NotConcurrent? = nil // expected-warning{{stored property 'nc' of 'Sendable'-conforming class 'C1' has non-Sendable type 'NotConcurrent'}}
340+
let nc: NotConcurrent? = nil // expected-warning{{stored property 'nc' of 'Sendable'-conforming class 'C1' contains non-Sendable type 'NotConcurrent'}}
341341
var x: Int = 0 // expected-warning{{stored property 'x' of 'Sendable'-conforming class 'C1' is mutable}}
342342
let i: Int = 0
343343
}

test/Concurrency/sendable_metatype_typecheck.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@ class Holder: @unchecked Sendable {
119119
}
120120

121121
enum E: Sendable {
122-
case q(Q.Type, Int) // expected-warning{{associated value 'q' of 'Sendable'-conforming enum 'E' has non-Sendable type 'any Q.Type'}}
122+
case q(Q.Type, Int) // expected-warning{{associated value 'q' of 'Sendable'-conforming enum 'E' contains non-Sendable type 'any Q.Type'}}
123123
}
124124

125125
struct S: Sendable {
126-
var tuple: ([Q.Type], Int) // expected-warning{{stored property 'tuple' of 'Sendable'-conforming struct 'S' has non-Sendable type 'any Q.Type'}}
126+
var tuple: ([Q.Type], Int) // expected-warning{{stored property 'tuple' of 'Sendable'-conforming struct 'S' contains non-Sendable type 'any Q.Type'}}
127127
}
128128

129129
extension Q {

test/Concurrency/weak_ref_sendability.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ final class CheckSendability3: Sendable {
4949
}
5050

5151
final class CheckSendability4: Sendable {
52-
// expected-error@+1 {{stored property 'x' of 'Sendable'-conforming class 'CheckSendability4' has non-Sendable type 'NS?'}}
52+
// expected-error@+1 {{stored property 'x' of 'Sendable'-conforming class 'CheckSendability4' contains non-Sendable type 'NS'}}
5353
weak let x: NS? = nil
5454
}
5555

0 commit comments

Comments
 (0)