Skip to content

[stdlib] Isolate Array bridging behavior for ABI stability #14717

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 27, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion stdlib/public/core/Arrays.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -2381,6 +2381,15 @@ extension ${Self} {
%end

#if _runtime(_ObjC)
// We isolate the bridging of the Cocoa Array -> Swift Array here so that
// in the future, we can eagerly bridge the Cocoa array. We need this function
// to do the bridging in an ABI safe way. Even though this looks useless,
// DO NOT DELETE!
@_versioned internal
func _bridgeCocoaArray<T>(_ _immutableCocoaArray: _NSArrayCore) -> Array<T> {
return Array(_buffer: _ArrayBuffer(nsArray: _immutableCocoaArray))
}

extension Array {
@_inlineable
public // @SPI(Foundation)
Expand Down Expand Up @@ -2414,7 +2423,7 @@ extension Array {
/// is a reference type).
@_inlineable
public init(_immutableCocoaArray: _NSArrayCore) {
self = Array(_buffer: _ArrayBuffer(nsArray: _immutableCocoaArray))
self = _bridgeCocoaArray(_immutableCocoaArray)
}
}
#endif
Expand Down