I'm having this compilation error and I don't really know what's the best way to solve it.
In this basic exemple, the error says Type 'any Leg' cannot conform to 'Leg'
.
I've tried to mirror the same hierarchy that I have in my project, but I just couldn't come up with something better at the moment (it's not about dogs obviously).
protocol Animal {
var legs: [Leg] { get }
}
class Dog: Animal {
var legs: [Leg] = []
}
protocol Leg {}
protocol ZoneOfBody {}
extension Array: ZoneOfBody where Element: Leg {}
func test() -> ZoneOfBody {
let dog = Dog()
return dog.legs // <---- The compilation error is here
}
What possibilities do I have ? Thanks in advance