I have got this code:
protocol GenericProtocol: class {
    associatedtype type
    func funca(component: type)
}
class MyType<T> {
    weak var delegate: GenericProtocol? // First error
    var t: T
    init(t: T) {
        self.t = t
    }
    func finished() {
        delegate?.funca(component: t) // Second error
    }
}
class UsingGenericProtocol: GenericProtocol {
    let myType: MyType<Int>
    typealias type = Int
    init() {
        myType = MyType<Int>(t: 0)
    }
    func funca(component: Int) {
    }
}
I want to use delegates with a given type. The code will not compile because I got this errors:
Protocol 'GenericProtocol' can only be used as a generic constraint because it has Self or associated type requirements
And:
Member 'funca' cannot be used on value of protocol type 'GenericProtocol'; use a generic constraint instead
I can omit this error by removing the type from the protocol, make it Any and then casting it to the right type, but I thought generics should cover this problem. Is there any way I can get this code to compile? Thanks.
 
     
    