@@ -1291,40 +1291,6 @@ public func _setUpCast<DerivedValue, BaseValue>(_ source: Set<DerivedValue>)
1291
1291
return builder.take()
1292
1292
}
1293
1293
1294
- #if _runtime(_ObjC)
1295
-
1296
- /// Implements an unconditional upcast that involves bridging.
1297
- ///
1298
- /// The cast can fail if bridging fails.
1299
- ///
1300
- /// - Precondition: `SwiftValue` is bridged to Objective-C
1301
- /// and requires non-trivial bridging.
1302
- public func _setBridgeToObjectiveC<SwiftValue, ObjCValue>(
1303
- _ source: Set<SwiftValue>
1304
- ) -> Set<ObjCValue> {
1305
- _sanityCheck(_isClassOrObjCExistential(ObjCValue.self))
1306
- _sanityCheck(!_isBridgedVerbatimToObjectiveC(SwiftValue.self))
1307
-
1308
- var result = Set<ObjCValue>(minimumCapacity: source.count)
1309
- let valueBridgesDirectly =
1310
- _isBridgedVerbatimToObjectiveC(SwiftValue.self) ==
1311
- _isBridgedVerbatimToObjectiveC(ObjCValue.self)
1312
-
1313
- for member in source {
1314
- var bridgedMember: ObjCValue
1315
- if valueBridgesDirectly {
1316
- bridgedMember = unsafeBitCast(member, to: ObjCValue.self)
1317
- } else {
1318
- let bridged: AnyObject = _bridgeAnythingToObjectiveC(member)
1319
- bridgedMember = unsafeBitCast(bridged, to: ObjCValue.self)
1320
- }
1321
- result.insert(bridgedMember)
1322
- }
1323
- return result
1324
- }
1325
-
1326
- #endif
1327
-
1328
1294
@_silgen_name("_swift_setDownCastIndirect")
1329
1295
public func _setDownCastIndirect<SourceValue, TargetValue>(
1330
1296
_ source: UnsafePointer<Set<SourceValue>>,
@@ -1389,64 +1355,6 @@ public func _setDownCastConditional<BaseValue, DerivedValue>(
1389
1355
})
1390
1356
}
1391
1357
1392
- #if _runtime(_ObjC)
1393
-
1394
- /// Implements an unconditional downcast that involves bridging.
1395
- ///
1396
- /// - Precondition: At least one of `SwiftValue` is a bridged value
1397
- /// type, and the corresponding `ObjCValue` is a reference type.
1398
- public func _setBridgeFromObjectiveC<ObjCValue, SwiftValue>(
1399
- _ source: Set<ObjCValue>
1400
- ) -> Set<SwiftValue> {
1401
- let result: Set<SwiftValue>? = _setBridgeFromObjectiveCConditional(source)
1402
- _precondition(result != nil, "This set cannot be bridged from Objective-C")
1403
- return result!
1404
- }
1405
-
1406
- /// Implements a conditional downcast that involves bridging.
1407
- ///
1408
- /// If the cast fails, the function returns `nil`. All checks should be
1409
- /// performed eagerly.
1410
- ///
1411
- /// - Precondition: At least one of `SwiftValue` is a bridged value
1412
- /// type, and the corresponding `ObjCValue` is a reference type.
1413
- public func _setBridgeFromObjectiveCConditional<
1414
- ObjCValue, SwiftValue
1415
- >(
1416
- _ source: Set<ObjCValue>
1417
- ) -> Set<SwiftValue>? {
1418
- _sanityCheck(_isClassOrObjCExistential(ObjCValue.self))
1419
- _sanityCheck(!_isBridgedVerbatimToObjectiveC(SwiftValue.self))
1420
-
1421
- let valueBridgesDirectly =
1422
- _isBridgedVerbatimToObjectiveC(SwiftValue.self) ==
1423
- _isBridgedVerbatimToObjectiveC(ObjCValue.self)
1424
-
1425
- var result = Set<SwiftValue>(minimumCapacity: source.count)
1426
- for value in source {
1427
- // Downcast the value.
1428
- var resultValue: SwiftValue
1429
- if valueBridgesDirectly {
1430
- if let bridgedValue = value as? SwiftValue {
1431
- resultValue = bridgedValue
1432
- } else {
1433
- return nil
1434
- }
1435
- } else {
1436
- if let bridgedValue = _conditionallyBridgeFromObjectiveC(
1437
- _reinterpretCastToAnyObject(value), SwiftValue.self) {
1438
- resultValue = bridgedValue
1439
- } else {
1440
- return nil
1441
- }
1442
- }
1443
- result.insert(resultValue)
1444
- }
1445
- return result
1446
- }
1447
-
1448
- #endif
1449
-
1450
1358
//===--- APIs unique to Dictionary<Key, Value> ----------------------------===//
1451
1359
1452
1360
/// A collection whose elements are key-value pairs.
@@ -2216,66 +2124,6 @@ public func _dictionaryUpCast<DerivedKey, DerivedValue, BaseKey, BaseValue>(
2216
2124
return result
2217
2125
}
2218
2126
2219
- #if _runtime(_ObjC)
2220
-
2221
- /// Implements an unconditional upcast that involves bridging.
2222
- ///
2223
- /// The cast can fail if bridging fails.
2224
- ///
2225
- /// - Precondition: `SwiftKey` and `SwiftValue` are bridged to Objective-C,
2226
- /// and at least one of them requires non-trivial bridging.
2227
- @inline(never)
2228
- @_semantics("stdlib_binary_only")
2229
- public func _dictionaryBridgeToObjectiveC<
2230
- SwiftKey, SwiftValue, ObjCKey, ObjCValue
2231
- >(
2232
- _ source: Dictionary<SwiftKey, SwiftValue>
2233
- ) -> Dictionary<ObjCKey, ObjCValue> {
2234
-
2235
- // Note: We force this function to stay in the swift dylib because
2236
- // it is not performance sensitive and keeping it in the dylib saves
2237
- // a new kilobytes for each specialization for all users of dictionary.
2238
-
2239
- _sanityCheck(
2240
- !_isBridgedVerbatimToObjectiveC(SwiftKey.self) ||
2241
- !_isBridgedVerbatimToObjectiveC(SwiftValue.self))
2242
- _sanityCheck(
2243
- _isClassOrObjCExistential(ObjCKey.self) ||
2244
- _isClassOrObjCExistential(ObjCValue.self))
2245
-
2246
- var result = Dictionary<ObjCKey, ObjCValue>(minimumCapacity: source.count)
2247
- let keyBridgesDirectly =
2248
- _isBridgedVerbatimToObjectiveC(SwiftKey.self) ==
2249
- _isBridgedVerbatimToObjectiveC(ObjCKey.self)
2250
- let valueBridgesDirectly =
2251
- _isBridgedVerbatimToObjectiveC(SwiftValue.self) ==
2252
- _isBridgedVerbatimToObjectiveC(ObjCValue.self)
2253
- for (key, value) in source {
2254
- // Bridge the key
2255
- var bridgedKey: ObjCKey
2256
- if keyBridgesDirectly {
2257
- bridgedKey = unsafeBitCast(key, to: ObjCKey.self)
2258
- } else {
2259
- let bridged: AnyObject = _bridgeAnythingToObjectiveC(key)
2260
- bridgedKey = unsafeBitCast(bridged, to: ObjCKey.self)
2261
- }
2262
-
2263
- // Bridge the value
2264
- var bridgedValue: ObjCValue
2265
- if valueBridgesDirectly {
2266
- bridgedValue = unsafeBitCast(value, to: ObjCValue.self)
2267
- } else {
2268
- let bridged: AnyObject? = _bridgeAnythingToObjectiveC(value)
2269
- bridgedValue = unsafeBitCast(bridged, to: ObjCValue.self)
2270
- }
2271
-
2272
- result[bridgedKey] = bridgedValue
2273
- }
2274
-
2275
- return result
2276
- }
2277
- #endif
2278
-
2279
2127
@_silgen_name("_swift_dictionaryDownCastIndirect")
2280
2128
public func _dictionaryDownCastIndirect<SourceKey, SourceValue,
2281
2129
TargetKey, TargetValue>(
@@ -2364,89 +2212,6 @@ public func _dictionaryDownCastConditional<
2364
2212
return result
2365
2213
}
2366
2214
2367
- #if _runtime(_ObjC)
2368
- /// Implements an unconditional downcast that involves bridging.
2369
- ///
2370
- /// - Precondition: At least one of `SwiftKey` or `SwiftValue` is a bridged value
2371
- /// type, and the corresponding `ObjCKey` or `ObjCValue` is a reference type.
2372
- public func _dictionaryBridgeFromObjectiveC<
2373
- ObjCKey, ObjCValue, SwiftKey, SwiftValue
2374
- >(
2375
- _ source: Dictionary<ObjCKey, ObjCValue>
2376
- ) -> Dictionary<SwiftKey, SwiftValue> {
2377
- let result: Dictionary<SwiftKey, SwiftValue>? =
2378
- _dictionaryBridgeFromObjectiveCConditional(source)
2379
- _precondition(result != nil, "dictionary cannot be bridged from Objective-C")
2380
- return result!
2381
- }
2382
-
2383
- /// Implements a conditional downcast that involves bridging.
2384
- ///
2385
- /// If the cast fails, the function returns `nil`. All checks should be
2386
- /// performed eagerly.
2387
- ///
2388
- /// - Precondition: At least one of `SwiftKey` or `SwiftValue` is a bridged value
2389
- /// type, and the corresponding `ObjCKey` or `ObjCValue` is a reference type.
2390
- public func _dictionaryBridgeFromObjectiveCConditional<
2391
- ObjCKey, ObjCValue, SwiftKey, SwiftValue
2392
- >(
2393
- _ source: Dictionary<ObjCKey, ObjCValue>
2394
- ) -> Dictionary<SwiftKey, SwiftValue>? {
2395
- _sanityCheck(
2396
- _isClassOrObjCExistential(ObjCKey.self) ||
2397
- _isClassOrObjCExistential(ObjCValue.self))
2398
- _sanityCheck(
2399
- !_isBridgedVerbatimToObjectiveC(SwiftKey.self) ||
2400
- !_isBridgedVerbatimToObjectiveC(SwiftValue.self))
2401
-
2402
- let keyBridgesDirectly =
2403
- _isBridgedVerbatimToObjectiveC(SwiftKey.self) ==
2404
- _isBridgedVerbatimToObjectiveC(ObjCKey.self)
2405
- let valueBridgesDirectly =
2406
- _isBridgedVerbatimToObjectiveC(SwiftValue.self) ==
2407
- _isBridgedVerbatimToObjectiveC(ObjCValue.self)
2408
-
2409
- var result = Dictionary<SwiftKey, SwiftValue>(minimumCapacity: source.count)
2410
- for (key, value) in source {
2411
- // Downcast the key.
2412
- var resultKey: SwiftKey
2413
- if keyBridgesDirectly {
2414
- if let bridgedKey = key as? SwiftKey {
2415
- resultKey = bridgedKey
2416
- } else {
2417
- return nil
2418
- }
2419
- } else {
2420
- if let bridgedKey = _conditionallyBridgeFromObjectiveC(
2421
- _reinterpretCastToAnyObject(key), SwiftKey.self) {
2422
- resultKey = bridgedKey
2423
- } else {
2424
- return nil
2425
- }
2426
- }
2427
-
2428
- // Downcast the value.
2429
- var resultValue: SwiftValue
2430
- if valueBridgesDirectly {
2431
- if let bridgedValue = value as? SwiftValue {
2432
- resultValue = bridgedValue
2433
- } else {
2434
- return nil
2435
- }
2436
- } else {
2437
- if let bridgedValue = _conditionallyBridgeFromObjectiveC(
2438
- _reinterpretCastToAnyObject(value), SwiftValue.self) {
2439
- resultValue = bridgedValue
2440
- } else {
2441
- return nil
2442
- }
2443
- }
2444
-
2445
- result[resultKey] = resultValue
2446
- }
2447
- return result
2448
- }
2449
- #endif
2450
2215
//===--- APIs templated for Dictionary and Set ----------------------------===//
2451
2216
2452
2217
%{
0 commit comments