protocol EmptyInitializable {
init()
}
@propertyWrapper
struct PropertyWrapper: EmptyInitializable {
let wrappedValue: Int
init(_ wrappedValue: Int = 0) {
self.wrappedValue = wrappedValue
}
}
// This one lools redundent
extension PropertyWrapper {
public init() {
wrappedValue = 0
}
}
为什么我们需要在底部进行扩展?为什么编译器不能弄清楚,它struct PropertyWrapper
已经符合 的要求protocol EmptyInitializable
?看起来好丑啊...
PS我相信它以前确实在类似的情况下起作用过。