struct Handler {}
protocol HandlerWire {
var handler: Handler { get }
}
protocol InteractorWire {
associatedtype Interactor : HandlerWire
var interactor: Interactor { get }
}
class BaseModerator {}
// Trailing 'where' clause for extension of non-generic type 'BaseModerator'
extension BaseModerator : HandlerWire where Self : InteractorWire {
var handler: Handler {
return interactor.handler
}
}
All I want to express here is, please conform to HandlerWire and provide a default implementation for var handler: Handler { get }on the subclass if that subclass also conforms to InteractorWire.
My reasoning is that conditional conformances are great for dynamic dispatch, but I yet do not see a worthy reason to check for something that is known at compile time in this manner – whether BaseModerator conforms to InteractorWire. A similar flow would be "if I declared a variable named x over there, do ...". But the point is you know whether you declared that variable or you can otherwise go and check and act accordingly. Whenever you use BaseModerator, it either conforms of not without depending on generic parameters. And retroactive conformances are handled separately as far as I understand.
It's kind of an allusion as well, since a non-protocol type is its own Self.