8000 'any Sendable' is ignored in function type conversions · Issue #81888 · swiftlang/swift · GitHub
[go: up one dir, main page]

Skip to content

'any Sendable' is ignored in function type conversions #81888

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

Open
Sweeper777 opened this issue May 31, 2025 · 0 comments
Open

'any Sendable' is ignored in function type conversions #81888

Sweeper777 opened this issue May 31, 2025 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels

Comments

@Sweeper777
Copy link
Sweeper777 commented May 31, 2025

Description

A function type involving any Sendable are treated as if it were Any. This allows function type conversions that is concurrency-unsafe. For example, () -> Any can be converted to () -> any Sendable, and (any Sendable) -> Void can be converted to (Any) -> Void.

Reproduction

class NotSendable {}

// all three of these compile!
func f1(x: @escaping () -> NotSendable) {
    let g: () -> any Sendable = x
}

func f2(x: @escaping () -> Any) {
    let g: () -> any Sendable = x
}

func f3(x: @escaping (any Sendable) -> Void) {
    let g: (Any) -> Void = x
}

Expected behavior

All three functions above should produce a compile time error.

Environment

swift-driver version: 1.115 Apple Swift version 6.0.2 (swiftlang-6.0.2.1.2 clang-1600.0.26.4)
Target: arm64-apple-macosx15.0

Also reproducible on 6.1.2 on SwiftFiddle.

Additional information

From a Stack Overflow post.

@Sweeper777 Sweeper777 added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels May 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels
Projects
None yet
Development

No branches or pull requests

1 participant
0