Is there a way to improve the protocol conformance diagnostics? While
is a good start, it's not so useful, if you have a large struct
. In this case, it would be great to know which properties are prevent the conformance.
Is there a way to improve the protocol conformance diagnostics? While
is a good start, it's not so useful, if you have a large struct
. In this case, it would be great to know which properties are prevent the conformance.
Full error message gives you that info
/blah/main.swift:3:8: error: type 'Foo' does not conform to protocol 'Decodable'
struct Foo: Codable {
^
Swift.Decodable:2:5: note: protocol requires initializer 'init(from:)' with type 'Decodable'
init(from decoder: Decoder) throws
^
/blah/main.swift:5:9: note: cannot automatically synthesize 'Decodable' because 'NonCodable' does not conform to 'Decodable'
let b: NonCodable
^
/blah/main.swift:3:8: error: type 'Foo' does not conform to protocol 'Encodable'
struct Foo: Codable {
^
Swift.Encodable:2:10: note: protocol requires function 'encode(to:)' with type 'Encodable'
func encode(to encoder: Encoder) throws
^
/blah/main.swift:5:9: note: cannot automatically synthesize 'Encodable' because 'NonCodable' does not conform to 'Encodable'
let b: NonCodable
^
Amazing! It never occurred to me that this window does truncate the error message. Thanks a lot!