Avatar
Avatar
Yuta Saito
@swift-5.7.3 -warn-concurrency -Xfrontend -parse-as-library import Foundation @MainActor func foo() -> () -> Void { { print(Thread.isMainThread) } } @main struct Main { @MainActor static func main() async { let f = foo() let t = Task.detached { f() } _ = await t.value } } (edited)
falsestderr:<stdin>:16:7: warning: capture of 'f' with non-sendable type '() -> Void' in a `@Sendable` closure f() ^ <stdin>:16:7: note: a function type must be marked '@Sendable' to conform to 'Sendable' f() ^ (edited)