# Data class inheritance

**URL:** https://discuss.kotlinlang.org/t/data-class-inheritance/4107
**Category:** Uncategorized
**Created:** [August 9, 2017, 6:58pm UTC](https://discuss.kotlinlang.org/t/data-class-inheritance/4107 "2017-08-09T18:58:24Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![afonichev](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/afonichev/32/3492_2.png) [@afonichev](https://discuss.kotlinlang.org/u/afonichev)
#### Post date: [August 9, 2017, 8:27pm UTC](https://discuss.kotlinlang.org/t/data-class-inheritance/4107/5 "2017-08-09T20:27:48Z")

</div>

> [@yole](#):
>
> Yes, that’s correct. It’s impossible to generate a copy() method that could copy the properties of a non-data class, because there is no way to establish the correspondence between constructor parameters and properties.

Ok, I understand you, then I’ll have to use this

```
object Xml {

    ...

    fun <T> copy(value: Any, clazz: Class<T>): T = deserialize(serialize(value), clazz)
}

```

Thanks for the help.

---

_[View the full topic](https://discuss.kotlinlang.org/t/data-class-inheritance/4107)._
