Thank you so much for your comments, @itaiferber , @Tony_Parker and @benrimmington !
I think that it would probably be best not to touch _DictionaryCodingKey
- and also to not expose any public CodingKey
implementation.
You mention a non-roundtripping CodingKey
implementation, @benrimmington :
First of all, I thought I understood enum CodingKey
conformance. I thought it was all done through the RawRepresentable
conformance, but as I can gather from your comment and from the example there's code synthesis involved. I did not know that. :-)
Secondly: Is this something that should be fixed? Or might this behavior be expected in case you craft a CodingKey
so cunningly? Isn't it you own 'responsibility' that a CodingKey
round-trips? I mean, it's easy to create CodingKey
s that do not:
struct Test: CodingKey {
var stringValue: String = "hello"
init?(stringValue: String) {
return nil
}
var intValue: Int? { return 23 }
init?(intValue: Int) {
return nil
}
}