Skip to content

Commit fe2c8ef

Browse files
committed
[Diagnostics] Use contains instead of has when non-Sendable type appears inside of a member type
(cherry picked from commit 3495c61)
1 parent ace1e52 commit fe2c8ef

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5869,8 +5869,8 @@ ERROR(non_sendable_keypath_capture,none,
58695869
(Type))
58705870
ERROR(non_concurrent_type_member,none,
58715871
"%select{stored property %2|associated value %2}1 of "
5872-
"'Sendable'-conforming %kind3 has non-Sendable type %0",
5873-
(Type, bool, DeclName, const ValueDecl *))
5872+
"'Sendable'-conforming %kind3 %select{contains|has}4 non-Sendable type %0",
5873+
(Type, bool, DeclName, const ValueDecl *, bool))
58745874
ERROR(concurrent_value_class_mutable_property,none,
58755875
"stored property %0 of 'Sendable'-conforming %kind1 is mutable",
58765876
(DeclName, const ValueDecl *))

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6832,7 +6832,7 @@ static bool checkSendableInstanceStorage(
68326832
member
68336833
->diagnose(diag::non_concurrent_type_member, type,
68346834
isa<EnumElementDecl>(member), member->getName(),
6835-
nominal)
6835+
nominal, type->isEqual(memberType))
68366836
.limitBehaviorWithPreconcurrency(
68376837
behavior, fromPreconcurrencyConformance ||
68386838
preconcurrencyBehavior.has_value());

test/Concurrency/concurrent_value_checking.swift

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

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

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 {

0 commit comments

Comments
 (0)