Skip to content

[🍒 5.9] Fix main executor check in startOnMainActor #65272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stdlib/public/Concurrency/Task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1598,7 +1598,7 @@ SWIFT_CC(swift)
static void swift_task_startOnMainActorImpl(AsyncTask* task) {
AsyncTask * originalTask = _swift_task_clearCurrent();
ExecutorRef mainExecutor = swift_task_getMainExecutor();
if (swift_task_getCurrentExecutor() != swift_task_getMainExecutor())
if (!swift_task_isCurrentExecutor(mainExecutor))
swift_Concurrency_fatalError(0, "Not on the main executor");
swift_retain(task);
swift_job_run(task, mainExecutor);
Expand Down
2 changes: 2 additions & 0 deletions stdlib/public/Concurrency/Task.swift
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ extension Task where Failure == Error {
@_spi(MainActorUtilities)
@MainActor
@available(SwiftStdlib 5.9, *)
@discardableResult
public static func startOnMainActor(
priority: TaskPriority? = nil,
@_inheritActorContext @_implicitSelfCapture _ work: __owned @Sendable @escaping @MainActor() async throws -> Success
Expand All @@ -213,6 +214,7 @@ extension Task where Failure == Never {
@_spi(MainActorUtilities)
@MainActor
@available(SwiftStdlib 5.9, *)
@discardableResult
public static func startOnMainActor(
priority: TaskPriority? = nil,
@_inheritActorContext @_implicitSelfCapture _ work: __owned @Sendable @escaping @MainActor() async -> Success
Expand Down