Skip to content

Commit 764c0c8

Browse files
committed
fix compile warning, which will be compile error in upcoming swift 6
1 parent f8d4d57 commit 764c0c8

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Source/SwiftyJSON/SwiftyJSON.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ public struct JSON {
236236
rawString = string
237237
case _ as NSNull:
238238
type = .null
239-
case nil:
239+
case Optional<Any>.none:
240240
type = .null
241241
case let array as [Any]:
242242
type = .array

Tests/SwiftJSONTests/RawRepresentableTests.swift

+6
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ class RawRepresentableTests: XCTestCase {
8484
if JSON(rawValue: NSObject()) != nil {
8585
XCTFail("Should not run into here")
8686
}
87+
88+
do {
89+
let n: Int? = nil
90+
let json = JSON(n as Any)
91+
XCTAssertEqual(json.type, .null)
92+
}
8793
}
8894

8995
func testArray() {

0 commit comments

Comments
 (0)