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> {
}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With