I am trying to take advantage of generics like so.
protocol Y { ... }
protocol X: Y { ... }
protocol A: Collection where Element == Y { ... }
protocol B: A where Element == X { ... }
I am getting the error on the definition of B
:
Same-type constraint type 'X' does not conform to required protocol 'Y'
But, X
does conform to Y
...
I tried using an intermediary associatedtype DataPoint
like so
protocol A: Collection where Element == DataPoint {
associatedtype DataPoint: Y
...
}
protocol B: A where DataPoint == X { ... }
But I get the same error. Is it possible to accomplish this sort of thing in Swift 4 or do I have to make two completely separate protocols?