Skip to content

Commit c63aa52

Browse files
committed
docs: document why Undoable uses nonisolated deinit with assumeIsolated
1 parent 5a6526a commit c63aa52

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

Sources/TextBuffer/Buffer/Undoable.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ public final class Undoable<Base>: @MainActor Buffer where Base: Buffer, Base.Ra
123123
self.init(base, undoManager: undoManager)
124124
}
125125

126+
// NB: Cannot use `isolated deinit` here. When a @MainActor class with
127+
// `isolated deinit` is deallocated without a running RunLoop (e.g. in
128+
// XCTest's command-line runner), the Swift 6.2 runtime tries to hop to
129+
// the MainActor for deinit execution and aborts (signal 6) when no
130+
// RunLoop services the hop. `MainActor.assumeIsolated` asserts main-thread
131+
// execution without requiring the actor hop mechanism.
126132
deinit {
127133
MainActor.assumeIsolated {
128134
undoManager?.removeAllActions(withTarget: self)

0 commit comments

Comments
 (0)