Skip to content

Commit 22e9dd9

Browse files
committed
Fix warnings
1 parent 556a2ed commit 22e9dd9

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Sources/Construct.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ public protocol Initializable : class {
44
}
55

66
/// Create a class or struct with a constructor method. Return a value of `property.type` for each property. Classes must conform to `Initializable`.
7-
public func construct<T>(_ type: T.Type = T.self, constructor: Property.Description throws -> Any) throws -> T {
7+
public func construct<T>(_ type: T.Type = T.self, constructor: (Property.Description) throws -> Any) throws -> T {
88
guard Metadata(type: T.self).isStructOrClass else { throw Error.notStructOrClass(type: T.self) }
99
if Metadata(type: T.self)?.kind == .struct {
1010
return try constructValueType(constructor)
@@ -15,7 +15,7 @@ public func construct<T>(_ type: T.Type = T.self, constructor: Property.Descript
1515
}
1616
}
1717

18-
private func constructValueType<T>(_ constructor: Property.Description throws -> Any) throws -> T {
18+
private func constructValueType<T>(_ constructor: (Property.Description) throws -> Any) throws -> T {
1919
guard Metadata(type: T.self)?.kind == .struct else { throw Error.notStructOrClass(type: T.self) }
2020
let pointer = UnsafeMutablePointer<T>(allocatingCapacity: 1)
2121
defer { pointer.deallocateCapacity(1) }
@@ -25,15 +25,15 @@ private func constructValueType<T>(_ constructor: Property.Description throws ->
2525
return pointer.pointee
2626
}
2727

28-
private func constructReferenceType<T>(_ value: T, constructor: Property.Description throws -> Any) throws -> T {
28+
private func constructReferenceType<T>(_ value: T, constructor: (Property.Description) throws -> Any) throws -> T {
2929
var copy = value
3030
var storage = mutableStorageForInstance(&copy)
3131
var values = [Any]()
3232
try constructType(storage: &storage, values: &values, properties: properties(T.self), constructor: constructor)
3333
return copy
3434
}
3535

36-
private func constructType(storage: inout UnsafeMutablePointer<Int>, values: inout [Any], properties: [Property.Description], constructor: Property.Description throws -> Any) throws {
36+
private func constructType(storage: inout UnsafeMutablePointer<Int>, values: inout [Any], properties: [Property.Description], constructor: (Property.Description) throws -> Any) throws {
3737
for property in properties {
3838
var value = try constructor(property)
3939
guard Reflection.value(value, is: property.type) else { throw Error.valueIsNotType(value: value, type: property.type) }
@@ -47,7 +47,7 @@ public func construct<T>(_ type: T.Type = T.self, dictionary: [String: Any]) thr
4747
return try construct(constructor: constructorForDictionary(dictionary))
4848
}
4949

50-
private func constructorForDictionary(_ dictionary: [String: Any]) -> Property.Description throws -> Any {
50+
private func constructorForDictionary(_ dictionary: [String: Any]) -> (Property.Description) throws -> Any {
5151
return { property in
5252
if let value = dictionary[property.key] {
5353
return value

0 commit comments

Comments
 (0)