Open simanerush opened 6 months ago
Update: the code in this issue already works, but the following (reduced from #75799) doesn't:
func usesFunction(_ block: @escaping @Sendable () -> Void) {}
func test () {
let closure: @MainActor () -> Void = {}
@MainActor func f() {}
usesFunction {
Task {
await closure() // ⚠️
await f() // ⚠️
}
}
}
I guess this is the same issue I'm seeing with this reproduction;
public struct Bar {
@MainActor func bar() { }
}
func append(_ body: @MainActor () -> Void) { }
append(Bar().bar) // ⚠️ Converting non-sendable function value to '@MainActor @Sendable () -> Void' may introduce data races
If I mark Bar: Sendable
(or internal so its inferred) then it's fine
or jump through another closure that must infer @Sendable
append { Bar().bar() } ✅
Description
No response
Reproduction
Expected behavior
The above should compile under SE-0434, because
f
is globally-isolated.Environment
Swift version 6.0-dev (LLVM ceb203a206ed550, Swift a5fdf158dc4292a)
Additional information
No response