diff --git a/Sources/Defaults/Defaults+Extensions.swift b/Sources/Defaults/Defaults+Extensions.swift index 17a2afc..ce2162e 100644 --- a/Sources/Defaults/Defaults+Extensions.swift +++ b/Sources/Defaults/Defaults+Extensions.swift @@ -132,7 +132,7 @@ extension Array: Defaults.Serializable where Element: Defaults.Serializable { } extension Dictionary: Defaults.Serializable where Key: LosslessStringConvertible & Hashable, Value: Defaults.Serializable { - public static var isNativelySupportedType: Bool { Value.isNativelySupportedType } + public static var isNativelySupportedType: Bool { (Key.self is String.Type) && Value.isNativelySupportedType } public static var bridge: Defaults.DictionaryBridge { Defaults.DictionaryBridge() } } diff --git a/Tests/DefaultsTests/DefaultsDictionaryTests.swift b/Tests/DefaultsTests/DefaultsDictionaryTests.swift index 8ca3d15..a34b462 100644 --- a/Tests/DefaultsTests/DefaultsDictionaryTests.swift +++ b/Tests/DefaultsTests/DefaultsDictionaryTests.swift @@ -57,6 +57,15 @@ final class DefaultsDictionaryTests: XCTestCase { XCTAssertEqual(Defaults[key]["0"], [newName, fixtureArray[1]]) } + func testIntKey() { + let fixture = [1: "x"] + let key = Defaults.Key<[Int: String]>("independentDictionaryIntKey", default: fixture) + XCTAssertEqual(Defaults[key][1], fixture[1]) + let newValue = "John" + Defaults[key][1] = newValue + XCTAssertEqual(Defaults[key][1], newValue) + } + func testType() { XCTAssertEqual(Defaults[.dictionary]["0"], fixtureDictionary["0"]) let newName = "Chen"