2 ms·
There's not much reification to be done when dealing with ObjC objects and calling ObjC methods. For example: let a = A() a.someMethod() let b
by mikeash 11y ago
There's not much reification to be done when dealing with ObjC objects and calling ObjC methods. For example:
let a = A()
a.someMethod()
let b = B()
b.someMethod()
If A and B are Swift types, then the code to invoke a.someMethod() might be substantially different from the code for b.someMethod(). There's struct versus class, final methods, the potential for inlining, maybe more.
If A and B are both Objective-C classes, however, then the code for the two invocations is identical. Both will compile down to a call to objc_msgSend, passing the object and the "someMethod" selector to it as parameters.
So yes, it looks like the types get erased on the ObjC end of things, but I don't think the Swift end of things has to care very much. It can emit code without any runtime casts or any adjustment for the actual generic type.