Avatar
@swift-5.9.2 -strict-concurrency=complete import Foundation func takeSendableClosure(_ c: @Sendable @escaping () -> ()) { Task.detached(operation: c) } let nonSendable: () -> () = {} takeSendableClosure(nonSendable) // 警告出る struct S { var nonSendableValue: () -> () @Sendable func mayUseNonSendableValue() { nonSendableValue() } } var count = 0 var s = S(nonSendableValue: { count += 1 }) takeSendableClosure(s.mayUseNonSendableValue) // 警告出ない for _ in 0..<10000 { takeSendableClosure(s.mayUseNonSendableValue) } print(count) sleep(1) print(count) (edited)