Skip to content

Commit 42f6455

Browse files
committed
[Concurrency] TildeSendable: Disallow Sendable suppression on actor declarations
1 parent 84d775e commit 42f6455

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/Sema/TypeCheckDeclPrimary.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,17 @@ class CheckRepressions {
133133
}
134134

135135
if (auto *TD = dyn_cast<const TypeDecl *>(decl)) {
136+
if (rpk == RepressibleProtocolKind::Sendable) {
137+
auto *C = dyn_cast<ClassDecl>(TD);
138+
if (C && C->isActor()) {
139+
diagnoseInvalid(
140+
repr, repr.getLoc(),
141+
diag::conformance_repression_only_on_struct_class_enum,
142+
ctx.getProtocol(*kp));
143+
return Type();
144+
}
145+
}
146+
136147
if (!(isa<StructDecl>(TD) || isa<ClassDecl>(TD) || isa<EnumDecl>(TD))) {
137148
diagnoseInvalid(repr, repr.getLoc(),
138149
diag::conformance_repression_only_on_struct_class_enum,

test/Sema/tilde_sendable.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,8 @@ do {
131131

132132
class Child2: Base, ~Sendable {}
133133
// expected-error@-1 {{cannot both conform to and suppress conformance to 'Sendable'}}
134+
135+
actor A: ~Sendable {
136+
// expected-error@-1 {{conformance to 'Sendable' can only be suppressed on structs, classes, and enums}}
137+
}
134138
}

0 commit comments

Comments
 (0)