Sorry for the late reply.
I did some tests and found out that inheritance with data classes can be tricky, specially if you have to set fields on the base class, since you cannot have arguments on the primary constructor that are not properties.
If the fields in the base class are auto generated (like Id, creation date), you can do something like this:
open class Base(
val id: Int? = null,
val dateCreated: LocalDateTime = LocalDateTime.now(),
val lastUpdated: LocalDateTime = LocalDateTime.now(),
data class Task(
var name: String,
var description: String? = null,
var dueDate: LocalDate? = null,
var done: Boolean = false
) : Base()
For more complex cases, I believe it is better to use normal classes.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.