mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
* Support extensions including conditional conformance * Correct access modifiers * More correct lookup for the synthesized declarations * Avoid printing decls in nested types (rdar://98025945)
46 lines
1.2 KiB
Plaintext
46 lines
1.2 KiB
Plaintext
|
|
enum Payload: Codable {
|
|
case plain(String)
|
|
case pair(key: String, value: String)
|
|
}
|
|
|
|
enum Payload_D: Decodable {
|
|
case plain(String)
|
|
case pair(key: String, value: String)
|
|
}
|
|
|
|
enum Payload_E: Encodable {
|
|
case plain(String)
|
|
case pair(key: String, value: String)
|
|
|
|
private enum CodingKeys: CodingKey {
|
|
case plain
|
|
case pair
|
|
}
|
|
|
|
private enum PlainCodingKeys: CodingKey {
|
|
case _0
|
|
}
|
|
|
|
private enum PairCodingKeys: CodingKey {
|
|
case key
|
|
case value
|
|
}
|
|
|
|
func encode(to encoder: any Encoder) throws {
|
|
var container = encoder.container(keyedBy: Payload_E.CodingKeys.self)
|
|
|
|
switch self {
|
|
case .plain(let a0):
|
|
var nestedContainer = container.nestedContainer(keyedBy: Payload_E.PlainCodingKeys.self, forKey: Payload_E.CodingKeys.plain)
|
|
|
|
try nestedContainer.encode(a0, forKey: Payload_E.PlainCodingKeys._0)
|
|
case .pair(let key, let value):
|
|
var nestedContainer = container.nestedContainer(keyedBy: Payload_E.PairCodingKeys.self, forKey: Payload_E.CodingKeys.pair)
|
|
|
|
try nestedContainer.encode(key, forKey: Payload_E.PairCodingKeys.key)
|
|
try nestedContainer.encode(value, forKey: Payload_E.PairCodingKeys.value)
|
|
}
|
|
}
|
|
}
|