Skip to content

Commit 960345e

Browse files
authored
Merge pull request #65272 from etcwilde/ewilde/5.9/fix-startOnMainActor
[🍒 5.9] Fix main executor check in startOnMainActor
2 parents 3946ef5 + f2ccc76 commit 960345e

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

stdlib/public/Concurrency/Task.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1598,7 +1598,7 @@ SWIFT_CC(swift)
15981598
static void swift_task_startOnMainActorImpl(AsyncTask* task) {
15991599
AsyncTask * originalTask = _swift_task_clearCurrent();
16001600
ExecutorRef mainExecutor = swift_task_getMainExecutor();
1601-
if (swift_task_getCurrentExecutor() != swift_task_getMainExecutor())
1601+
if (!swift_task_isCurrentExecutor(mainExecutor))
16021602
swift_Concurrency_fatalError(0, "Not on the main executor");
16031603
swift_retain(task);
16041604
swift_job_run(task, mainExecutor);

stdlib/public/Concurrency/Task.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ extension Task where Failure == Error {
192192
@_spi(MainActorUtilities)
193193
@MainActor
194194
@available(SwiftStdlib 5.9, *)
195+
@discardableResult
195196
public static func startOnMainActor(
196197
priority: TaskPriority? = nil,
197198
@_inheritActorContext @_implicitSelfCapture _ work: __owned @Sendable @escaping @MainActor() async throws -> Success
@@ -213,6 +214,7 @@ extension Task where Failure == Never {
213214
@_spi(MainActorUtilities)
214215
@MainActor
215216
@available(SwiftStdlib 5.9, *)
217+
@discardableResult
216218
public static func startOnMainActor(
217219
priority: TaskPriority? = nil,
218220
@_inheritActorContext @_implicitSelfCapture _ work: __owned @Sendable @escaping @MainActor() async -> Success

0 commit comments

Comments
 (0)