@@ -193,6 +193,33 @@ func _bridgeToObjectiveCUnconditionalAutorelease<T>(_ x: T) -> AnyObject
193
193
@_silgen_name ( " _swift_bridgeNonVerbatimToObjectiveC " )
194
194
func _bridgeNonVerbatimToObjectiveC< T> ( _ x: T ) -> AnyObject ?
195
195
196
+ /// Bridge an arbitrary value to an Objective-C object.
197
+ ///
198
+ /// - If `T` is a class type, it is always bridged verbatim, the function
199
+ /// returns `x`;
200
+ ///
201
+ /// - otherwise, `T` conforms to `_ObjectiveCBridgeable`:
202
+ /// + if `T._isBridgedToObjectiveC()` returns `false`, then
203
+ /// we fall back to boxing (below);
204
+ /// + otherwise, returns the result of `x._bridgeToObjectiveC()`;
205
+ ///
206
+ /// - otherwise, we use **boxing** to bring the value into Objective-C.
207
+ /// The value is wrapped in an instance of a private Objective-C class
208
+ /// that is `id`-compatible and dynamically castable back to the type of
209
+ /// the boxed value, but is otherwise opaque.
210
+ ///
211
+ /// TODO: This should subsume `_bridgeToObjectiveC` above.
212
+ func _bridgeAnythingToObjectiveC< T> ( _: T ) -> AnyObject {
213
+ if _fastPath ( _isClassOrObjCExistential ( T . self) ) {
214
+ return unsafeBitCast ( x, to: AnyObject . self)
215
+ }
216
+ return _bridgeAnythingNonVerbatimToObjectiveC ( x)
217
+ }
218
+
219
+ // TODO: This should subsume `_bridgeNonVerbatimToObjectiveC` above.
220
+ @_silgen_name ( " _swift_bridgeAnythingNonVerbatimToObjectiveC " )
221
+ func _bridgeAnythingNonVerbatimToObjectiveC< T> ( _ x: T ) -> AnyObject
222
+
196
223
/// Convert `x` from its Objective-C representation to its Swift
197
224
/// representation.
198
225
///
@@ -523,4 +550,5 @@ extension AutoreleasingUnsafeMutablePointer {
523
550
Builtin . unreachable ( )
524
551
}
525
552
}
553
+
526
554
#endif
0 commit comments