File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -40,8 +40,13 @@ extension Set : _ObjectTypeBridgeable {
40
40
if let o = obj as? Element {
41
41
set. insert ( o)
42
42
} else {
43
- failedConversion = true
44
- stop. pointee = true
43
+ // here obj must be a swift type
44
+ if let nsObject = _SwiftValue. store ( obj) as? Element {
45
+ set. insert ( nsObject)
46
+ } else {
47
+ failedConversion = true
48
+ stop. pointee = true
49
+ }
45
50
}
46
51
}
47
52
} else if type ( of: source) == _NSCFSet. self {
Original file line number Diff line number Diff line change @@ -35,7 +35,8 @@ class TestNSSet : XCTestCase {
35
35
( " test_CountedSetObjectCount " , test_CountedSetObjectCount) ,
36
36
( " test_CountedSetAddObject " , test_CountedSetAddObject) ,
37
37
( " test_CountedSetRemoveObject " , test_CountedSetRemoveObject) ,
38
- ( " test_CountedSetCopying " , test_CountedSetCopying)
38
+ ( " test_CountedSetCopying " , test_CountedSetCopying) ,
39
+ ( " test_mutablesetWithDictionary " , test_mutablesetWithDictionary) ,
39
40
]
40
41
}
41
42
@@ -226,5 +227,13 @@ class TestNSSet : XCTestCase {
226
227
XCTAssertTrue ( NSArray ( array: setMutableCopy. allObjects) . index ( of: entry) != NSNotFound)
227
228
}
228
229
}
229
-
230
+
231
+ func test_mutablesetWithDictionary( ) {
232
+ let aSet = NSMutableSet ( )
233
+ let dictionary = NSMutableDictionary ( )
234
+ let key = NSString ( string: " Hello " )
235
+ aSet. add ( [ " world " : " again " ] )
236
+ dictionary. setObject ( aSet, forKey: key)
237
+ XCTAssertNotNil ( dictionary. description) //should not crash
238
+ }
230
239
}
You can’t perform that action at this time.
0 commit comments