Skip to content

Commit 415715e

Browse files
authored
Merge pull request #72863 from hborla/nested-sendable-class
[Concurrency] Classes nested in actors are not semantically final.
2 parents 2841b59 + 537d7a5 commit 415715e

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

lib/AST/Decl.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3701,10 +3701,12 @@ bool ValueDecl::isSemanticallyFinal() const {
37013701
return true;
37023702
}
37033703

3704-
// As are members of actor types.
3705-
if (auto classDecl = getDeclContext()->getSelfClassDecl()) {
3706-
if (classDecl->isAnyActor())
3707-
return true;
3704+
// As are methods/accessors of actor types.
3705+
if (!isa<TypeDecl>(this)) {
3706+
if (auto classDecl = getDeclContext()->getSelfClassDecl()) {
3707+
if (classDecl->isAnyActor())
3708+
return true;
3709+
}
37083710
}
37093711

37103712
// For everything else, the same as 'final'.

test/Concurrency/sendable_conformance_checking.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,9 @@ extension SendableExtSub: @unchecked Sendable {}
181181
// Still want to know about same-class redundancy
182182
class MultiConformance: @unchecked Sendable {} // expected-note {{'MultiConformance' declares conformance to protocol 'Sendable' here}}
183183
extension MultiConformance: @unchecked Sendable {} // expected-error {{redundant conformance of 'MultiConformance' to protocol 'Sendable'}}
184+
185+
@available(SwiftStdlib 5.1, *)
186+
actor MyActor {
187+
// expected-warning@+1 {{non-final class 'Nested' cannot conform to 'Sendable'; use '@unchecked Sendable'; this is an error in the Swift 6 language mode}}
188+
class Nested: Sendable {}
189+
}

0 commit comments

Comments
 (0)