Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Foundation/NSDictionary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ open class NSMutableDictionary : NSDictionary {
guard type(of: self) === NSDictionary.self || type(of: self) === NSMutableDictionary.self else {
NSRequiresConcreteImplementation()
}
_storage[(aKey as! NSObject)] = _SwiftValue.store(anObject)
_storage[_SwiftValue.store(aKey)] = _SwiftValue.store(anObject)
}

public convenience required init() {
Expand Down
7 changes: 7 additions & 0 deletions TestFoundation/TestNSDictionary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class TestNSDictionary : XCTestCase {
("test_mutableCopying", test_mutableCopying),
("test_writeToFile", test_writeToFile),
("test_initWithContentsOfFile", test_initWithContentsOfFile),
("test_settingWithStringKey", test_settingWithStringKey),
]
}

Expand Down Expand Up @@ -222,6 +223,12 @@ class TestNSDictionary : XCTestCase {
}
}

func test_settingWithStringKey() {
let dict = NSMutableDictionary()
// has crashed in the past
dict["stringKey"] = "value"
}

private func createTestFile(_ path: String, _contents: Data) -> String? {
let tempDir = NSTemporaryDirectory() + "TestFoundation_Playground_" + NSUUID().uuidString + "/"
do {
Expand Down