File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -10,21 +10,19 @@ extension MapInitializable {
10
10
throw MapError . cannotInitialize ( type: Self . self, from: try type ( of: map. get ( ) ) )
11
11
}
12
12
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
17
14
guard let initializable = property. type as? MapInitializable . Type else {
18
15
throw MapError . notMapInitializable ( property. type)
19
16
}
17
+
20
18
switch dictionary [ property. name] ?? . null {
21
19
case . null:
22
20
guard let expressibleByNilLiteral = property. type as? ExpressibleByNilLiteral . Type else {
23
21
throw RuntimeReflectionError . requiredValueMissing ( key: property. name)
24
22
}
25
- try property . set ( value : expressibleByNilLiteral. init ( nilLiteral: ( ) ) , on : & self )
23
+ return expressibleByNilLiteral. init ( nilLiteral: ( ) )
26
24
case let x:
27
- try property . set ( value : initializable. init ( map: x) , on : & self )
25
+ return try initializable. init ( map: x)
28
26
}
29
27
}
30
28
}
You can’t perform that action at this time.
0 commit comments