In the previous section, we've seen an example of associated type. Let's see what we mean when mentioning Self requirement.
Consider the following protocol:
protocol Thing {
associatedtype AType
}
struct Node: Thing {
typealias AType = Thing // Self associated type
}
Because Node conforms to Thing and sets its AType associatedtype to itself via typealias, you would probably imagine the following code would work:
let thing: Thing = Node()
Unfortunately, it doesn't. This is what we call a Self requirement and you will be hit by the same problem:
Protocol 'Thing' can only be used as a generic constraint because it has Self or associated type requirements