Skip to content

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

Open
@dnadoba

Description

@dnadoba

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

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.concurrencyFeature: umbrella label for concurrency language features

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions