mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Improve experience of derivation of Codable types
* Introduce diagnostics that explain why derivation of Encodable/Decodable fail rather than just silently failing * Allow properties with default values to be omitted from CodingKeys enum and from encoding/decoding * If `CodingKeys` is a typealias, reach through it more consistently to get at the final target type * Add unit tests to confirm this new behavior for classes and structs NOTE: Although this made the diff bigger, standalone variables named "type" have been renamed to "target" throughout, since the word "type" may be ambiguous and makes debugging impossible. "target" is unique.
This commit is contained in:
@@ -43,13 +43,10 @@ class SimpleChildClass : SimpleClass {
|
||||
}
|
||||
}
|
||||
|
||||
// These are wrapped in a dummy function to avoid binding a global variable.
|
||||
func foo() {
|
||||
// They should receive synthesized init(from:) and an encode(to:).
|
||||
let _ = SimpleChildClass.init(from:)
|
||||
let _ = SimpleChildClass.encode(to:)
|
||||
// They should receive synthesized init(from:) and an encode(to:).
|
||||
let _ = SimpleChildClass.init(from:)
|
||||
let _ = SimpleChildClass.encode(to:)
|
||||
|
||||
// The synthesized CodingKeys type should not be accessible from outside the
|
||||
// class.
|
||||
let _ = SimpleChildClass.CodingKeys.self // expected-error {{'CodingKeys' is inaccessible due to 'private' protection level}}
|
||||
}
|
||||
// The synthesized CodingKeys type should not be accessible from outside the
|
||||
// class.
|
||||
let _ = SimpleChildClass.CodingKeys.self // expected-error {{'CodingKeys' is inaccessible due to 'private' protection level}}
|
||||
|
||||
Reference in New Issue
Block a user