I played a bit with Swift 4 and Codable and got stuck in a script with nested protocols that all conform to Codable .
A simplified example is as follows:
protocol CodableSomething: Codable {} protocol CodableAnotherThing: Codable { var something: CodableSomething { get } } struct Model: CodableAnotherThing { var something: CodableSomething }
This code generates build errors using Xcode 9 Beta 5:
- Type 'Model' does not comply with 'Decodable' protocol
- Type 'Model' does not comply with the protocol 'Encodable'
Now I did not expect these errors, because I realized that compliance with these protocols would be automatically generated by the compiler, when in fact I could not even implement this correspondence manually without assembly errors. I also tried several different approaches to solving this nested model structure using Codable , but I just couldn't get it to work.
My question is : Is this a compiler bug (still beta) or am I something wrong?
source share