Tuesday, November 17, 2020

Does Swift Call the Protocol Extension or Subclass Implementation?

JP Simard:

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.

Greg Titus:

What is going on here is that the MyProtocol conformance is on MySuperclass. Thus the witnesses are determined right there, and since MySuperclass doesn’t implement myFunction, 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.


Hask++.m Lover

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!

Leave a Comment