https://kotlinlang.org logo
#announcements
Title
# announcements
t

tschuchort

10/02/2019, 9:39 PM
I have a pretty big hierarchy of sealed classes where all the leafs are data classes. Basically every subclass is just the superclass plus some extra values. Sometimes the subclasses are even identical except for the name, which signifies a different kind of the object. How can I construct values of this class hierarchy without having lots of code duplication? Delegation is hardly possible, since the common superclasses are sealed and thus can't be extended to make delegate objects for them. Basically what I want to do is to have one function that makes `Car`s and then take that
Car
and promote it a
BMW
or
Toyota
by adding some values to it.
k

Kroppeb

10/02/2019, 11:42 PM
I have a similar problem, and because some reflection was already being done I decided to just use more reflection
k

karelpeeters

10/07/2019, 10:04 AM
There is this relevant issue: https://youtrack.jetbrains.com/issue/KT-15471