stdlib: Dictionary, Set: allow querying for a mismatched type when bridged

Swift's Dictionary and Set are typed, but when bridged to NSDictionary
and NSSet they should behave accordingly, that is, allow querying for
keys of arbitrary types.

rdar://problem/23679193
This commit is contained in:
Dmitri Gribenko
2016-05-16 15:07:25 -07:00
parent b4c7c1f54e
commit 0868b6f70c
4 changed files with 71 additions and 6 deletions

View File

@@ -3275,7 +3275,9 @@ final internal class _Native${Self}StorageOwner<${TypeParametersDecl}>
@warn_unused_result
internal func bridgingObjectForKey(_ aKey: AnyObject)
-> AnyObject? {
let nativeKey = _forceBridgeFromObjectiveC(aKey, Key.self)
guard let nativeKey = _conditionallyBridgeFromObjectiveC(aKey, Key.self)
else { return nil }
let (i, found) = nativeStorage._find(
nativeKey, startBucket: nativeStorage._bucket(nativeKey))
if found {