Commit 0ea9a19 1 parent 1d32f36 commit 0ea9a19 Copy full SHA for 0ea9a19
File tree 2 files changed +5
-6
lines changed
FirebaseFunctions/Sources
2 files changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -541,10 +541,8 @@ enum FunctionsConstants {
541
541
private func callableResult( fromResponseData data: Data ) throws -> HTTPSCallableResult {
542
542
let processedData = try processedData ( fromResponseData: data)
543
543
let json = try responseDataJSON ( from: processedData)
544
- // TODO: Refactor `decode(_:)` so it either returns a non-optional object or throws
545
544
let payload = try serializer. decode ( json)
546
- // TODO: Remove `as Any` once `decode(_:)` is refactored
547
- return HTTPSCallableResult ( data: payload as Any )
545
+ return HTTPSCallableResult ( data: payload)
548
546
}
549
547
550
548
private func processedData( fromResponseData data: Data ) throws -> Data {
Original file line number Diff line number Diff line change @@ -58,16 +58,17 @@ final class FunctionsSerializer {
58
58
}
59
59
}
60
60
61
- func decode( _ object: Any ) throws -> AnyObject ? {
61
+ func decode( _ object: Any ) throws -> Any {
62
62
// Return these types as is. PORTING NOTE: Moved from the bottom of the func for readability.
63
63
if let dict = object as? NSDictionary {
64
64
if let requestedType = dict [ " @type " ] as? String {
65
65
guard let value = dict [ " value " ] as? String else {
66
66
// Seems like we should throw here - but this maintains compatibility.
67
67
return dict
68
68
}
69
- let result = try decodeWrappedType ( requestedType, value)
70
- if result != nil { return result }
69
+ if let result = try decodeWrappedType ( requestedType, value) {
70
+ return result
71
+ }
71
72
72
73
// Treat unknown types as dictionaries, so we don't crash old clients when we add types.
73
74
}
You can’t perform that action at this time.
0 commit comments