Skip to content

Commit 387d757

Browse files
author
chantu
committed
fix inheritance test fail & update podspec to 5.0.0-beta
1 parent 98e1355 commit 387d757

4 files changed

Lines changed: 21 additions & 9 deletions

File tree

HandyJSON.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Pod::Spec.new do |s|
33
s.author = {'xuyecan' => '[email protected]'}
44
s.license = 'Apache License 2.0'
55
s.requires_arc = true
6-
s.version = '4.2.1'
6+
s.version = '5.0.0-beta'
77
s.homepage = "https://github.com/alibaba/handyjson"
88
s.name = "HandyJSON"
99

@@ -18,5 +18,5 @@ Pod::Spec.new do |s|
1818
s.watchos.deployment_target = '2.0'
1919
s.tvos.deployment_target = '9.0'
2020

21-
s.pod_target_xcconfig = { 'SWIFT_VERSION' => '4.2' }
21+
s.pod_target_xcconfig = { 'SWIFT_VERSION' => '5.0' }
2222
end

HandyJSONDemo/ViewController.swift

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,23 @@ struct Subject: HandyJSON {
4444
var lessonPeriod: Int?
4545
}
4646

47-
class Student: HandyJSON {
48-
var id: String?
47+
class Person: HandyJSON {
4948
var name: String?
5049
var age: Int?
51-
var grade: Grade = .One
5250
var height: Int?
5351
var gender: Gender?
52+
53+
required init() {}
54+
}
55+
56+
class IdentifiedPerson: Person {
57+
var id: String?
58+
59+
required init() {}
60+
}
61+
62+
class Student: IdentifiedPerson {
63+
var grade: Grade = .One
5464
var className: String?
5565
var teacher: Teacher = Teacher()
5666
var subjects: [Subject]?

Source/HelpingMapper.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public class HelpingMapper {
110110
if let _converter = converter {
111111
let assignmentClosure = { (jsonValue: Any?) -> Any? in
112112
if let _value = jsonValue{
113-
if let object = _value as? NSObject{
113+
if let object = _value as? NSObject {
114114
if let str = String.transform(from: object){
115115
return _converter(str)
116116
}

Source/Metadata.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,10 @@ extension Metadata {
125125

126126
var isSwiftClass: Bool {
127127
get {
128-
let lowbit = self.pointer.pointee.databits & 1
129-
return lowbit == 1
128+
// see include/swift/Runtime/Config.h macro SWIFT_CLASS_IS_SWIFT_MASK
129+
// it can be 1 or 2 depending on environment
130+
let lowbit = self.pointer.pointee.databits & 3
131+
return lowbit != 0
130132
}
131133
}
132134

@@ -146,7 +148,7 @@ extension Metadata {
146148
}
147149

148150
// ignore objc-runtime layer
149-
guard let metaclass = Metadata.Class(anyType: superclass), metaclass.isSwiftClass else {
151+
guard let metaclass = Metadata.Class(anyType: superclass) else {
150152
return nil
151153
}
152154

0 commit comments

Comments
 (0)