Is there a way to make this kind of type hierarchy...
# announcements
r
Is there a way to make this kind of type hierarchy? in this case
MutableVector2
cannot extend both
Vector2
and
MutableVector<...>
as it makes
T
conflict with itself.
d
Usually not. There’s a very common related issue that crops up in C++ https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern which causes a lot of problems with inheritance. The basic version of the problem looks something like:
class Foo: Bar<Foo>
and then trying to extend Foo to create Foo2 in a way that you want to it to also extend
Bar<Foo2>
which tends to lead to a bunch of problems. Thankfully this pattern is relatively rare on the JVM.
r
Interesting, thanks for the link