Skip to content

[Concurrency] Task.immediate returning Never error must not have throwing op #82372

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

Conversation

ktoso
Copy link
Contributor

@ktoso ktoso commented Jun 20, 2025

Ofc when we return an Never error, the operation cannot be throwing, this fixes that.

The API thankfully is AEIC, and the other place has silgenname already so we're safe from ABI trouble here.

rdar://153855920

@@ -46,7 +47,7 @@ extension Task where Failure == ${FAILURE_TYPE} {
public static func startSynchronously(
name: String? = nil,
priority: TaskPriority? = nil,
@_implicitSelfCapture @_inheritActorContext(always) _ operation: sending @isolated(any) @escaping () async throws -> Success
@_implicitSelfCapture @_inheritActorContext(always) _ operation: sending @isolated(any) @escaping () async ${THROWS} -> Success
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this method has hardcoded silgen name already

@@ -79,7 +80,7 @@ extension Task where Failure == ${FAILURE_TYPE} {
public static func immediate(
name: String? = nil,
priority: TaskPriority? = nil,
@_implicitSelfCapture @_inheritActorContext(always) operation: sending @isolated(any) @escaping () async throws -> Success
@_implicitSelfCapture @_inheritActorContext(always) operation: sending @isolated(any) @escaping () async ${THROWS} -> Success
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this method is AEIC

@@ -256,7 +257,7 @@ extension Task where Failure == ${FAILURE_TYPE} {
@discardableResult
public static func startOnMainActor(
priority: TaskPriority? = nil,
${OPERATION_PARAM}
@_inheritActorContext @_implicitSelfCapture _ operation: __owned @Sendable @escaping @MainActor () async ${THROWS} -> Success
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same as OPERATION_PARAM but moved to the THROWS pattern we use elsewhere in this file

@ktoso ktoso requested review from xedin and hborla June 20, 2025 00:38
@ktoso
Copy link
Contributor Author

ktoso commented Jun 20, 2025

@swift-ci please smoke test

@@ -1,5 +1,4 @@
// RUN: %target-build-swift -swift-version 6 %s -strict-concurrency=complete -Xfrontend -verify

// RUN: %target-swift-frontend -parse-as-library -swift-version 6 -strict-concurrency=complete -emit-sil -verify %s
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I don't think -strict-concurrency=complete is viable if -swift-version 6 is set.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true, i'll fix that :)

@ktoso
Copy link
Contributor Author

ktoso commented Jun 23, 2025

@swift-ci please smoke test

@ktoso ktoso merged commit a28515e into swiftlang:main Jun 24, 2025
3 checks passed
@ktoso ktoso deleted the wip-NeverErrorTaskShouldNotThrowInOperation branch June 24, 2025 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants