It seems to me that
@convention(block) blocks should be considered at compile-time to conform to
AnyObject. It's already an object pointer at runtime, and casting to
AnyObject preserves the existing pointer (this can be confirmed at the REPL).
The primary use-case for having this be considered to conform to
AnyObject is the ability to use
Unmanaged to explicitly control its lifetime (extremely useful for passing ownership of a block to a queue to ensure it deallocates on that queue). I could just cast it to
AnyObject but then I'd have to do an
as! cast back and I don't like that unsafety. My workaround in PMHTTP uses a wrapper
private class to hold the block, which is doable but annoying and involves otherwise-unnecessary allocation (though in this case the block in question isn't
@convention(block) so this pitch wouldn't actually solve it here, but it would for the work I'm trying to do right now).
There's probably other scenarios where having such a block inherit from
AnyObject would be useful as well, but
Unmanaged is the only one I can think of off the top of my head.