What solved that problem for me are associated types
Consider the following implementation:
// [ all protocols etc from before incl. ]
protocol OtherFunctionality {
associatedtype Thing: BaseProtocol
var thing: Thing { get }
}
final class OtherRealImplmentation<Thing: SomeExtraProtocol>: OtherFunctionality {
var thing: Thing
init(thing: Thing) {
self.thing = thing
}
}
The interesting part here is that the typeclass value of Thing isn't decided until the protocol is adopted (that is in OtherRealImplementation) and is still subject to inheritance which can be used for some cool DRY code wow Here is a link to the relevant swift docs which explain that concept really well