On 2015-07-14 13:59:51 +0000, Jacob Carlborg <d...@me.com> said:
On 2015-07-14 03:11, Michel Fortin wrote:
More or less. If you define an `extern (Objective-C)` class in D (once
all my work is merged), you can use it and derive from it in Swift. If
you define an `@objc` class in Swift you can use it from Objective-C and
from D, but you can't derive from it.
Do you know why you can't derive from it?
I'm not sure. Apple's documentation says: "You cannot subclass a Swift
class in Objective-C." I assume there could be a variety of reasons,
such as more aggressive optimizations.
Note that the Swift ABI isn't stable yet. So the above might change at
But they need to follow the Objective-C ABI, for the @objc classes. I
guess they technically can change the Objective-C ABI if they want to.
Actually, they only need to follow it up what they guaranty will work.
If you debug some Swift code mixed with Objective-C, you'll notice that
every call to a Swift method from Objective-C first passes through a
thunk function (not dissimilar to my first D/Objective-C bridge made
using D template mixins). Now, suppose you override this function from
the Objective-C side, only the thunk gets overriden and Swift calles
and Objective-C callers will no longer call the same function.
I haven't verified anything, but that's my theory.