Protocol inheritance/composition ignores shared base protocol

Alternatively, don't use existentials.

protocol SomeFunctionality {
  associatedtype Thing: BaseProtocol
  var thing: Thing { get }
}

protocol WidelyUsedProtocol: SomeFunctionality { }
protocol BaseProtocol { }
protocol SomeExtraProtocol: BaseProtocol { }

final class RealImplmentation<Thing: SomeExtraProtocol>: WidelyUsedProtocol {
  var thing: Thing
  init(thing: Thing) { self.thing = thing }
}

Previous discussion: Using subtypes in the implementation of protocol properties and function return values

5 Likes