Skip to content

Commit 609ba73

Browse files
committed
stdlib: add SPI for bridging for Foundation
1 parent 987acd3 commit 609ba73

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

stdlib/public/SDK/Foundation/Foundation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ extension Array : _ObjectiveCBridgeable {
501501

502502
@_semantics("convertToObjectiveC")
503503
public func _bridgeToObjectiveC() -> NSArray {
504-
return unsafeBitCast(self._buffer._asCocoaArray() as AnyObject, to: NSArray.self)
504+
return unsafeBitCast(self._bridgeToObjectiveCImpl(), to: NSArray.self)
505505
}
506506

507507
public static func _forceBridgeFromObjectiveC(

stdlib/public/core/Arrays.swift.gyb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2091,6 +2091,11 @@ public func != <Element : Equatable>(
20912091

20922092
#if _runtime(_ObjC)
20932093
extension Array {
2094+
public // @SPI(Foundation)
2095+
func _bridgeToObjectiveCImpl() -> AnyObject {
2096+
return _buffer._asCocoaArray()
2097+
}
2098+
20942099
/// Tries to downcast the source `NSArray` as our native buffer type.
20952100
/// If it succeeds, creates a new `Array` around it and returns that.
20962101
/// Returns `nil` otherwise.

0 commit comments

Comments
 (0)