[swift-dev] Unmanaged API flip flop
Jordan Rose
jordan_rose at apple.com
Tue Jul 5 11:24:28 CDT 2016
> On Jul 4, 2016, at 13:32, Kyle Jessup via swift-dev <swift-dev at swift.org> wrote:
>
> I have this code which uses Unmanaged and the API seems to vary depending on if I am using a 3.0 Preview or a development snapshot. I see it now when trying the June 13th/27th preview vs June 20th snapshot.
>
> class MyClass {}
>
> let holderObject = MyClass()
>
> #if FLIP // works with PREVIEW
> let leakyObject = UnsafeMutablePointer<Void>(OpaquePointer(bitPattern: Unmanaged.passRetained(holderObject)))
> #else // works with SNAPSHOT
> let leakyObject = Unmanaged.passRetained(holderObject).toOpaque()
> #endif
>
> #if FLIP // works with PREVIEW
> let unleakyObject = Unmanaged<MyClass>.fromOpaque(OpaquePointer(leakyObject)).takeRetainedValue()
> #else // works with SNAPSHOT
> let unleakyObject = Unmanaged<MyClass>.fromOpaque(leakyObject).takeRetainedValue()
> #endif
>
> I see the same difference between the previous snapshots and previews all the way back to the “false” preview of yore.
>
> Am I misunderstanding something about the API or is this a bug?
We just didn’t manage to get SE-0017 <https://github.com/apple/swift-evolution/blob/master/proposals/0017-convert-unmanaged-to-use-unsafepointer.md> in before the first preview. The development branch (your SNAPSHOT) is the one that will match the final Swift 3.
Jordan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20160705/3c231648/attachment.html>
More information about the swift-dev
mailing list