This is an automated email from the ASF dual-hosted git repository.
jensg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/thrift.git
The following commit(s) were added to refs/heads/master by this push:
new 0198542 THRIFT-5195: Handle Thrift union type sending for Swift
Client: Swift Patch: Eric Chen
0198542 is described below
commit 0198542201a6bd7e09ebd5a8b1ac14d3cb2b2bb7
Author: Eric Chen <[email protected]>
AuthorDate: Fri May 22 22:05:11 2020 -0700
THRIFT-5195: Handle Thrift union type sending for Swift
Client: Swift
Patch: Eric Chen
This closes #2154
---
lib/swift/Sources/TStruct.swift | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/swift/Sources/TStruct.swift b/lib/swift/Sources/TStruct.swift
index f120833..d0a1a4b 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!