Skip to content

Commit bf0942d

Browse files
committed
Fix enum initializations … merged in from jseibert@64f75b5
1 parent 3fd90b9 commit bf0942d

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

Sources/GraphQL/Map/MapInitializable.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,19 @@ extension MapInitializable {
1010
throw MapError.cannotInitialize(type: Self.self, from: try type(of: map.get()))
1111
}
1212

13-
self = try createInstance()
14-
let info = try typeInfo(of: Self.self)
15-
16-
for property in info.properties {
13+
self = try createInstance() { property in
1714
guard let initializable = property.type as? MapInitializable.Type else {
1815
throw MapError.notMapInitializable(property.type)
1916
}
17+
2018
switch dictionary[property.name] ?? .null {
2119
case .null:
2220
guard let expressibleByNilLiteral = property.type as? ExpressibleByNilLiteral.Type else {
2321
throw RuntimeReflectionError.requiredValueMissing(key: property.name)
2422
}
25-
try property.set(value: expressibleByNilLiteral.init(nilLiteral: ()), on: &self)
23+
return expressibleByNilLiteral.init(nilLiteral: ())
2624
case let x:
27-
try property.set(value: initializable.init(map: x), on: &self)
25+
return try initializable.init(map: x)
2826
}
2927
}
3028
}

0 commit comments

Comments
 (0)