diff --git a/CHANGELOG.md b/CHANGELOG.md index e700b9d0..baed470b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,22 @@ +## Main + +#### Breaking + +* None. + +#### Enhancements + +* Build without warnings with Swift 6 compiler. + [SimplyDanny](https://github.com/SimplyDanny) + +* Generate docs cleanly with Swift 6 compiler. + [John Fairhurst](https://github.com/johnfairh) + [#821]((https://github.com/realm/SourceKitten/issues/821) + +#### Bug Fixes + +* None. + ## 0.36.0 ##### Breaking diff --git a/Source/SourceKittenFramework/JSONOutput.swift b/Source/SourceKittenFramework/JSONOutput.swift index bccfcaf2..2adfb298 100644 --- a/Source/SourceKittenFramework/JSONOutput.swift +++ b/Source/SourceKittenFramework/JSONOutput.swift @@ -43,28 +43,28 @@ public func toJSON(_ object: Any, options: JSONSerialization.WritingOptions? = n - returns: JSON-serializable value. */ public func toNSDictionary(_ dictionary: [String: SourceKitRepresentable]) -> NSDictionary { - var anyDictionary = [String: Any]() - for (key, object) in dictionary { - switch object { + func toNSDictionaryValue(_ value: SourceKitRepresentable) -> Any { + switch value { case let object as [SourceKitRepresentable]: - anyDictionary[key] = object.map { toNSDictionary($0 as! [String: SourceKitRepresentable]) } + return object.map { toNSDictionaryValue($0) } case let object as [[String: SourceKitRepresentable]]: - anyDictionary[key] = object.map { toNSDictionary($0) } + return object.map { toNSDictionary($0) } case let object as [String: SourceKitRepresentable]: - anyDictionary[key] = toNSDictionary(object) + return toNSDictionary(object) case let object as String: - anyDictionary[key] = object + return object case let object as Int64: - anyDictionary[key] = NSNumber(value: object) + return NSNumber(value: object) case let object as Bool: - anyDictionary[key] = NSNumber(value: object) + return NSNumber(value: object) case let object as Any: - anyDictionary[key] = object + return object default: fatalError("Should never happen because we've checked all SourceKitRepresentable types") } } - return anyDictionary.bridge() + + return dictionary.mapValues(toNSDictionaryValue).bridge() } #if !os(Linux)