Skip to content

Commit

Permalink
fix compile warning, which will be compile error in upcoming swift 6
Browse files Browse the repository at this point in the history
  • Loading branch information
luoxiu committed Oct 31, 2022
1 parent f8d4d57 commit 764c0c8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Source/SwiftyJSON/SwiftyJSON.swift
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public struct JSON {
rawString = string
case _ as NSNull:
type = .null
case nil:
case Optional<Any>.none:
type = .null
case let array as [Any]:
type = .array
Expand Down
6 changes: 6 additions & 0 deletions Tests/SwiftJSONTests/RawRepresentableTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ class RawRepresentableTests: XCTestCase {
if JSON(rawValue: NSObject()) != nil {
XCTFail("Should not run into here")
}

do {
let n: Int? = nil
let json = JSON(n as Any)
XCTAssertEqual(json.type, .null)
}
}

func testArray() {
Expand Down

0 comments on commit 764c0c8

Please sign in to comment.