Using these protocol definitions:
protocol Presenter: AnyObject {
typealias InteractorType
var interactor: InteractorType { get }
}
protocol Activable: AnyObject {
var active: Bool { get set }
}
extension Activable where Self: Presenter, Self.InteractorType: Activable {
var active: Bool {
get { return interactor.active }
set { interactor.active = newValue }
}
}
protocol MyInteractorLike: Activable {}
And classes implementing them:
class MyInteractor: MyInteractorLike {
var active = false
}
class MyPresenter: PresenterLike, Activable {
let interactor: MyInteractorLike
init(interactor: MyInteractorLike) {
self.interactor = interactor
}
}
I would get an error:
MyPresenter does not conform to protocol Activable
However, when I redefine dependency as a concrete class instead of protocol:
class MyPresenter: PresenterLike, Activable {
let interactor: MyInteractor
init(interactor: MyInteractor) {
self.interactor = interactor
}
}
Everything is peachy. It looks like there is a problem with matching protocol extension if protocol's associated type is resolved to yet another protocol and not a concrete type.
So I was wondering: am I missing something? Is this a known issue? Do you know of any workarounds?