Skip to content

Commit

Permalink
Swift.type(of: x)
Browse files Browse the repository at this point in the history
  • Loading branch information
winddpan committed Feb 1, 2024
1 parent 480916e commit 80707b3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ struct ModelMemberPropertyContainer {

var text = """
let \(transformerVar) = \(transformerExpr)
let \(tempJsonVar) = try? container.decode(type: type(of: \(transformerVar)).JSON.self, keys: [\(member.codingKeys.joined(separator: ", "))], nestedKeys: [\(member.nestedKeys.joined(separator: ", "))])
let \(tempJsonVar) = try? container.decode(type: Swift.type(of: \(transformerVar)).JSON.self, keys: [\(member.codingKeys.joined(separator: ", "))], nestedKeys: [\(member.nestedKeys.joined(separator: ", "))])
"""

if let initializerExpr = member.initializerExpr {
Expand All @@ -90,7 +90,7 @@ struct ModelMemberPropertyContainer {

return text
} else {
let body = "container.decode(type: type(of: self.\(member.name)), keys: [\(member.codingKeys.joined(separator: ", "))], nestedKeys: [\(member.nestedKeys.joined(separator: ", "))])"
let body = "container.decode(type: Swift.type(of: self.\(member.name)), keys: [\(member.codingKeys.joined(separator: ", "))], nestedKeys: [\(member.nestedKeys.joined(separator: ", "))])"

if let initializerExpr = member.initializerExpr {
return "self.\(member.name) = (try? \(body)) ?? (\(initializerExpr))"
Expand Down
2 changes: 1 addition & 1 deletion Tests/CodableWrapperTests/TransformTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ struct DateModel_produce: Codable {

init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: AnyCodingKey.self)
let time = try container.decode(type: type(of: DateWrapper.transformer).JSON.self, keys: ["time"], nestedKeys: [])
let time = try container.decode(type: Swift.type(of: DateWrapper.transformer).JSON.self, keys: ["time"], nestedKeys: [])
self.time = DateWrapper.transformer.transformFromJSON(time)
}

Expand Down

0 comments on commit 80707b3

Please sign in to comment.