How do I cast an __NSMallocBlock__ to its underlying type in Swift 3?
<p>I had <a href="https://stackoverflow.com/a/39512988/17294">a trick</a> to help test <code>UIAlertController</code> that worked in Swift 2.x:</p>

<pre><code>extension UIAlertController {

    typealias AlertHandler = @convention(block) (UIAlertAction) -&gt; Void

    func tapButtonAtIndex(index: Int) {
        let block = actions[index].valueForKey("handler")
        let handler = unsafeBitCast(block, AlertHandler.self)

        handler(actions[index])
    }

}
</code></pre>

<p>This fails under Swift 3.x with <code>fatal error: can't unsafeBitCast between types of different sizes</code>, which tempts me to believe there might be a way to make the cast work. Can anyone figure it out?</p>