Reputation: 8637
The following Swift code repeatedly crashes the compiler. What am I missing?
protocol Props {
typealias ComponentType: Component<Self>
}
class Component<PropsType: Props> {
}
class FooProps : Props {
typealias ComponentType = FooComponent<FooProps>
}
class FooComponent<PropsType: Props> : Component<PropsType> {
}
Upvotes: 6
Views: 228
Reputation: 19524
There have been some good discussions on the use of generics in protocols.
http://schani.wordpress.com/2014/06/03/playing-with-swift/
http://schani.wordpress.com/2014/06/11/associated-types-considered-weird
That second article is quite illuminating for your issue. Simply put, swift doesn't have generic types for protocols. Hope this was useful.
Upvotes: 2