英文:
Sendability of function types in property does not match requirement in protocol
问题
我正在尝试添加一个协议,该协议具有Process的所有属性和函数,但我看到了关于terminationHandler
的警告。
我希望不会看到这个警告,因为@Sendable
已经添加到了terminationHandler
。
英文:
I am trying to add a protocol which has all the attributes and functions of a Process but I see a warning with terminationHandler
.
I was hoping not to see this warning since @Sendable
is already added to terminationHandler
.
protocol ProcessProtocol {
var executableURL: URL? { get set }
var arguments: [String]? { get set }
var environment: [String : String]? { get set }
var currentDirectoryURL: URL? { get set }
var standardInput: Any? { get set }
var standardOutput: Any? { get set }
var standardError: Any? { get set }
func run() throws
func interrupt()
func terminate()
func suspend() -> Bool
func resume() -> Bool
var processIdentifier: Int32 { get }
var isRunning: Bool { get }
var terminationStatus: Int32 { get }
var terminationReason: Process.TerminationReason { get }
var terminationHandler: (@Sendable (Process) -> Void)? { get set }
var qualityOfService: QualityOfService { get set }
}
extension Process: ProcessProtocol {}
答案1
得分: 1
以下是翻译好的内容:
这确实有点奇怪,因为您的协议签名与开发者文档中Process - terminationHandler
所示的签名完全匹配。移除@Sendable
注释实际上解决了警告,不太清楚为什么。我会向Apple提交一个关于此问题的错误报告。
英文:
It is a bit odd indeed, because your protocol signature exactly matches what the Developer Documentation signature shows for Process - terminationHandler
. Removing the @Sendable
notation actually resolves the warning, not sure why. I'd submit a bug report to Apple regarding this.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论