Open
Description
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