Swift ';可均衡';无法在扩展中自动合成
这项工作:Swift ';可均衡';无法在扩展中自动合成,swift,swift4,protocol-extension,Swift,Swift4,Protocol Extension,这项工作: // Conformance to protocol correctly synthesized by compiler struct MyStruct: Equatable { } 这并不是: struct MyStruct { } // Doesn't work, even though the extension is in the same file extension MyStruct: Equatable { } 错误很明显: 无法在扩展中自动合成“Equata
// Conformance to protocol correctly synthesized by compiler
struct MyStruct: Equatable {
}
这并不是:
struct MyStruct {
}
// Doesn't work, even though the extension is in the same file
extension MyStruct: Equatable {
}
错误很明显:
无法在扩展中自动合成“Equatable”的实现
我担心的是,根据Swift的建议,这应该是允许的:
SE-0185:合成可均衡的
和可散列的
一致性
用户必须选择自动合成,将其类型声明为equalable
或Hashable
,而不实现任何要求。此一致性必须是原始类型声明的一部分,或在同一文件的扩展名中(以确保可以从扩展名访问private和fileprivate成员)
它说这是在Swift 4.1()中实现的
然而,在尝试编译时,我得到了前面显示的错误。我使用的是Ubuntu 16.04,这两个版本的swift都失败了:
Swift版本4.1-dev(LLVM 260a172ffb,Clang cd84be6c42,Swift 05b1b2be7c)
Swift版本4.2-dev(LLVM d30879863e,Clang 041fd44ebe,Swift b08fb12358)
我错过了什么吗?好消息 2018年6月5日的最新开发快照按预期运行:
- (Ubuntu 16.04)
坏消息
最新发布的版本不起作用。在我看来像是一个bug。可能是……大约在……实现的。这是swift中的一个bug,已记录。现在找不到中继链接