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?

Thanks,
-Kyle
_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev

Reply via email to