Skip to content

Commit 98b1494

Browse files
authored
Merge pull request #82669 from DougGregor/isolated-deinit-main-actor-mode
2 parents b2f5252 + 78464f8 commit 98b1494

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6069,10 +6069,9 @@ computeDefaultInferredActorIsolation(ValueDecl *value) {
60696069
sendableConformanceRequiresNonisolated(nominalTypeDecl))
60706070
return { };
60716071

6072-
// FIXME: deinit should be implicitly MainActor too.
60736072
if (isa<TypeDecl>(value) || isa<ExtensionDecl>(value) ||
6074-
isa<AbstractStorageDecl>(value) || isa<FuncDecl>(value) ||
6075-
isa<ConstructorDecl>(value)) {
6073+
isa<AbstractStorageDecl>(value) ||
6074+
isa<AbstractFunctionDecl>(value)) {
60766075
// Preconcurrency here is used to stage the diagnostics
60776076
// when users select `@MainActor` default isolation with
60786077
// non-strict concurrency modes (pre Swift 6).

test/Concurrency/assume_mainactor.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
class Klass {
99
// Implicit deinit
1010
// CHECK: // Klass.deinit
11-
// CHECK-NEXT: // Isolation: unspecified
11+
// CHECK-NEXT: // Isolation: global_actor. type: MainActor
1212
// CHECK-NEXT: sil hidden [ossa] @$s16assume_mainactor5KlassCfd : $@convention(method) (@guaranteed Klass) -> @owned Builtin.NativeObject {
1313

1414
// Implicit deallocating deinit
1515
// CHECK: // Klass.__deallocating_deinit
1616
// CHECK-NEXT: // Isolation: nonisolated
1717
// CHECK-NEXT: sil hidden [ossa] @$s16assume_mainactor5KlassCfD : $@convention(method) (@owned Klass) -> () {
18+
// CHECK: swift_task_deinitOnExecutor
1819

1920
// Implicit allocating init
2021
// CHECK: // Klass.__allocating_init()
@@ -66,6 +67,16 @@ struct NonIsolatedStructContainingKlass {
6667
// CHECK-NEXT: sil hidden [ossa] @$s16assume_mainactor32NonIsolatedStructContainingKlassVACycfC : $@convention(method) (@thin NonIsolatedStructContainingKlass.Type) -> @owned NonIsolatedStructContainingKlass {
6768
}
6869

70+
struct NonCopyableStruct: ~Copyable {
71+
var x: Int
72+
var y: Int
73+
74+
// CHECK: NonCopyableStruct.deinit
75+
// CHECK-NEXT: Isolation: nonisolated
76+
deinit {
77+
}
78+
}
79+
6980
@globalActor
7081
actor CustomActor {
7182
static nonisolated let shared = CustomActor()

0 commit comments

Comments
 (0)