Avatar
omochimetaru 11/1/2017 1:22 AM
let a: @convention(block) () -> Int = { 42 } print("a") dump(a) print() type(of: a) // @conversion(block) () -> Int (a as AnyObject) === (a as AnyObject) // true print("a as AnyObject") print(type(of: a as AnyObject)) dump(a as AnyObject) print() let b: Any = a print("b") dump(b) type(of: b) // @conversion(block) () -> Int print() (b as AnyObject) === (b as AnyObject) // false print("b as AnyObject") print(type(of: b as AnyObject)) dump(b as AnyObject) print()
1:22 AM
a - (Function) a as AnyObject __NSMallocBlock__ - <__NSMallocBlock__: 0x608000243390> #0 - super: __NSMallocBlock - super: NSBlock - super: NSObject b - (Function) b as AnyObject _SwiftValue - (Function) #0 - super: NSObject
1:25 AM
Any経由からAnyObjectにするところで、 _SwiftValue にboxingされてるのが原因?
1:25 AM
a as AnyObject の結果は NSMallocBlock だから、ラップはされてない感じだね