关于Swift静态覆盖为最终版本的通告警告

关于Swift静态覆盖为最终版本的通告警告,swift,appkit,nsdocument,nsdocumentcontroller,Swift,Appkit,Nsdocument,Nsdocumentcontroller,我有一个NSDocumentController子类,需要知道它是否通过NSWindowRestoration协议还原了任何窗口 为此,我要重写的特定函数是: override open static func restoreWindow(withIdentifier identifier: NSUserInterfaceItemIdentifier, state: NSCoder, completionHandler: @escaping (NSWindow?, Error?) -> V

我有一个
NSDocumentController
子类,需要知道它是否通过
NSWindowRestoration
协议还原了任何窗口

为此,我要重写的特定函数是:

override open static func restoreWindow(withIdentifier identifier: NSUserInterfaceItemIdentifier, state: NSCoder, completionHandler: @escaping (NSWindow?, Error?) -> Void)
正如我所写的,这个函数在我想要的时候被调用,并且工作得很好。但是,我得到以下警告:

Static declarations are implicitly 'final'; use 'public' instead of 'open'
此警告包括一个看似有用的修复程序,用于将
open
转换为
public
。但是,当我接受时,我会得到以下错误:

Overriding static method must be as accessible as the declaration it overrides
此错误建议我将
public
替换为
open

我已经和苹果公司就这种循环行为展开了讨论。但是,我真的很想找到一种方法来平息这个警告。或者,也许还有另一种方法可以通知NSDocumentController子类它已恢复windows

要重现此错误,请使用Xcode 10创建一个新的应用程序项目,并包含以下代码。我只是在
AppDelegate
声明之后加入了它。默认情况下,项目配置为Swift 4.2和macOS 10.14版本

class MyDocumentController: NSDocumentController {
    override open static func restoreWindow(withIdentifier identifier: NSUserInterfaceItemIdentifier, state: NSCoder, completionHandler: @escaping (NSWindow?, Error?) -> Void) {
        super.restoreWindow(withIdentifier: identifier, state: state, completionHandler: completionHandler)
    }
}

感谢Martin R在Swift编译器中提供了该问题的链接。这个问题也有一个解决办法,确实为我解决了这个问题

通过在类Y的重写中实际使用类而不是静态,可以解决这个问题


在Xcode 10.1中,我没有收到关于覆盖公共静态的警告,你能发布一个吗?根据,这已经被修复了。就是这个!这个问题还包括一个变通办法。非常感谢你。