File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
stdlib/public/SDK/Foundation Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -1007,7 +1007,12 @@ extension NSMutableDictionary {
1007
1007
set {
1008
1008
// FIXME: Unfortunate that the `NSCopying` check has to be done at
1009
1009
// runtime.
1010
- self . setObject ( newValue, forKey: key as AnyObject as! NSCopying )
1010
+ let copyingKey = key as AnyObject as! NSCopying
1011
+ if let newValue = newValue {
1012
+ self . setObject ( newValue, forKey: copyingKey)
1013
+ } else {
1014
+ self . removeObject ( forKey: copyingKey)
1015
+ }
1011
1016
}
1012
1017
}
1013
1018
}
Original file line number Diff line number Diff line change @@ -17,5 +17,13 @@ tests.test("copy construction") {
17
17
let y = NSMutableDictionary ( dictionary: expected as NSDictionary )
18
18
expectEqual ( expected, y as NSDictionary as! Dictionary )
19
19
}
20
+ // rdar://problem/27875914
21
+ tests. test ( " subscript with Any " ) {
22
+ let d = NSMutableDictionary ( )
23
+ d [ " k " ] = " @this is how the world ends "
24
+ expectEqual ( ( d [ " k " ] ! as AnyObject ) . characterAtIndex ( 0 ) , 0x40 )
25
+ d [ " k " ] = nil
26
+ expectTrue ( d [ " k " ] == nil )
27
+ }
20
28
21
29
runAllTests ( )
You can’t perform that action at this time.
0 commit comments