Not able to pass self (which implements a protocol) to init method of a class instantiation.(Swift)
问题 I have a protocol like so public protocol FooProtocol { associatedType someType func doFoo(fooObject:someType) -> Void } I have a class that implements this protocol public class Foo<T> : FooProtocol { private let _doFoo : (T) -> Void init<P : FooProtocol where P.someType == T>(_dep : P) { _doFoo = _dep.doFoo } public func doFoo(fooObject: T) { _doFoo(fooObject) } } Everything upto here looks good to me, Now in another class I implement the FooProtocol with someType = MyType , then when I try