diff options
author | Eric Chen <taiyang.chen@gmail.com> | 2020-05-22 22:05:11 -0700 |
---|---|---|
committer | Jens Geyer <jensg@apache.org> | 2020-05-26 21:52:05 +0200 |
commit | 0198542201a6bd7e09ebd5a8b1ac14d3cb2b2bb7 (patch) | |
tree | 5a4723f611c40488dea543bcb7762fda0a14a20d /lib/swift | |
parent | 797fe252e0df18a24aa025d00d1d53c288ef2d4f (diff) | |
download | thrift-0198542201a6bd7e09ebd5a8b1ac14d3cb2b2bb7.tar.gz |
THRIFT-5195: Handle Thrift union type sending for Swift
Client: Swift
Patch: Eric Chen
This closes #2154
Diffstat (limited to 'lib/swift')
-rw-r--r-- | lib/swift/Sources/TStruct.swift | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/swift/Sources/TStruct.swift b/lib/swift/Sources/TStruct.swift index f12083346..d0a1a4bcd 100644 --- a/lib/swift/Sources/TStruct.swift +++ b/lib/swift/Sources/TStruct.swift @@ -62,7 +62,7 @@ public extension TStruct { for (propName, propValue) in mirror.children { guard let propName = propName else { continue } - if let tval = unwrap(any: propValue) as? TSerializable, let id = Self.fieldIds[propName] { + if let tval = unwrap(any: propValue, parent: mirror) as? TSerializable, let id = Self.fieldIds[propName] { try block(propName, tval, id) } } @@ -78,10 +78,10 @@ public extension TStruct { /// - parameter any: Any instance to attempt to unwrap /// /// - returns: Unwrapped Any as Optional<Any> - private func unwrap(any: Any) -> Any? { + private func unwrap(any: Any, parent: Mirror) -> Any? { let mi = Mirror(reflecting: any) - if mi.displayStyle != .optional { return any } + if parent.displayStyle != .enum && mi.displayStyle != .optional { return any } if mi.children.count == 0 { return nil } let (_, some) = mi.children.first! |