In Swift, this will give me compile error
class TestType {
}
protocol TestProtocol {
associatedtypes T: TestType
}
class TestClass<T: TestType> {
var x: TestProtocol<T>
}
It will give me a compiler error because TestProtocol "can only be used as a generic constraint". The correct way to do this which is much less clean (because it requires adding a generic parameter of TestProtocol everywhere when it is used)
class TestClass<T: TestProtocol> {
var x: T
}
So my question is, why doesn't Swift allow referring to a generic protocol simply as TestProtocol<T>
when T is already a typed parameter as in the above example ?