Does Swift Call the Protocol Extension or Subclass Implementation?
Pop Quiz, what does this Swift program print?
5 years on, it still takes me a few tries to properly reason through this. Especially in the real world when the code is a bit more spread out or complex to fit in a tweet.
What is going on here is that the
MyProtocol
conformance is onMySuperclass
. Thus the witnesses are determined right there, and sinceMySuperclass
doesn’t implementmyFunction
, the conformance uses the fallback implementation in the extension.Subclasses don’t/can’t “re-conform”
Previously:
2 Comments RSS · Twitter
Swift, reinventing the complexity of C++ ... poorly.
Swift seems such a poor fit for app development with all this insane complexity.
It's Haskell's type system (minus the numeric tower), wrapped in C++ syntax, on Objective-C's memory model.
Didn't you see that Developer Survey that Apple sent out 8 years ago? I guess I'm the only person who responded to that!