这是我的代码:
protocol Jard {
// Every Jard should have a food type refers to its own type
associatedtype FoodType: Food<Self>
}
class LittleJard: Jard {
// JardFood == Food<LittleJard> why does this not work?
typealias FoodType = JardFood
}
class Food<AnyFood> {
}
class JardFood: Food<LittleJard> {
}
编译错误:
类型'LittleJard'不符合协议'Jard'
为什么会这样?据我所知,JardFood
满足了FoodType
中LittleJard
的要求。