Skip to content

false Sendable warning if SE-299 (Extending Static Member Lookup in Generic Contexts) is used #64388

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
dnadoba opened this issue Mar 15, 2023 · 0 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. concurrency Feature: umbrella label for concurrency language features

Comments

@dnadoba
Copy link
Contributor

dnadoba commented Mar 15, 2023

Description
The following code produces a false positive Sendable warning Converting non-sendable function value to '@Sendable () async throws -> ()' may introduce data races if FooProtocol.make(_:) is called though static member lookup instead of on the concrete type:

public protocol FooProtocol {}
struct FooConcrete: FooProtocol {}

extension FooProtocol where Self == FooConcrete {
    static func make(
        _ body: @escaping @Sendable () async throws -> ()
    ) -> FooConcrete {
        FooConcrete()
    }
}

func baz1() -> some FooProtocol {
    .make {} // warning: Converting non-sendable function value to '@Sendable () async throws -> ()' may introduce data races
}

func baz2() -> some FooProtocol {
    FooConcrete.make {} // no warning
}

Steps to reproduce
compile the code above

Expected behavior
no warning

Environment

  • Swift compiler version info: swift-driver version: 1.75.2 Apple Swift version 5.8 (swiftlang-5.8.0.122.1 clang-1403.0.22.11.100)
  • Xcode version info: Version 14.3 beta 3 (14E5215c)

also tested with Swift 5.7.2 (5.7.2.135.5) and it produces the same warning

@dnadoba dnadoba added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. concurrency Feature: umbrella label for concurrency language features triage needed This issue needs more specific labels labels Mar 15, 2023
@angela-laar angela-laar self-assigned this Nov 2, 2023
@hborla hborla removed the triage needed This issue needs more specific labels label Apr 27, 2024
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. concurrency Feature: umbrella label for concurrency language features
Projects
None yet
Development

No branches or pull requests

3 participants