I am curious as to why this does not compile:
class SomeClass : BaseClass where T: BaseClass { ... }
class SomeDerivedClass : SomeClass
I get the following error: 'SomeClass' requires that 'SomeDerivedClass' inherit from 'BaseClass'
But doesn't it?
jrose
(Jordan Rose)
July 24, 2018, 4:22pm
2
The definition of "T" is missing from your example, so it's hard to say.
Actually, lost the definition of T through lack of escaping and HTML I guess....Trying again.
class BaseClass {}
class SomeClass<T> : BaseClass where T: BaseClass {}
class SomeDerivedClass : SomeClass<SomeDerivedClass> {}
I get the following error: 'SomeClass' requires that 'SomeDerivedClass' inherit from 'BaseClass'
1 Like
This looks like CRTP which is not yet supported in Swift. I don‘t remember if diagnostics were added (seems like from your posts), but it compiled before and simply stucked at the execution at some point.
2 Likes
CRTP is indeed what I was trying to get out of this...that tis a shame. Thanks!
Good news Swift 5 will allow CRTP . Thanks to @Slava_Pestov