Look in the Issues navigator (Command-5). There are error messages about the missing "encode" and "init" methods, but there is also a note message;
note: cannot automatically synthesize 'Encodable' because '[Flyable]' does not conform to 'Encodable'
This looks like a bug. If I write out the code that's supposed to be synthesized:
protocol Flyable: Codable {
var type: String { get }
var value: String { get }
}
struct Bird: Codable {
let canFly: [Flyable]
let name: String
enum CodeKeys: CodingKey
{
case canFly
case name
}
init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodeKeys.self)
canFly = try container.decode ([Flyable].self, forKey: .canFly)
name = try container.decode (String.self, forKey: .name)
}
func encode(to encoder: Encoder) throws
{
var container = encoder.container(keyedBy: CodeKeys.self)
try container.encode (canFly, forKey: .canFly)
try container.encode (name, forKey: .name)
}
}
there are no errors (in a playground), and clearly "canFly" is Encodable in line 24.