title: can I use kotlinx serializer with multiple sealed class levels as parents and a nested invocation?
body: <p>I am trying to use kotlinx <code>@Serializable</code> and Ive faced this issue:</p>
  <p>I have the following classes:</p>
  <pre><code>@Serializable
  sealed class GrandParent
  </code></pre>
  <p>a second one:</p>
  <pre><code>@Serializable
  sealed class Parent() : GrandParent() {
         abstract val id: String
      }
  </code></pre>
  <p>and a third one</p>
  <pre><code>@Serializable
  data class Child(
     override val id: String, ....
  ): Parent()
  </code></pre>
  <p>I'm needing of grandparent since I use it as a generic type in another class, which happen to also have a reference to the GrandParent class</p>
  <pre><code>@Serializable
  data class MyContent(
     override val id: String,
     ....
     val data: GrandParent, &lt;- so it has a self reference to hold nested levels
  ...): Parent()
  </code></pre>
  <p>Every time I try to run this I get an error...</p>
  <pre><code>Class 'MyContent' is not registered for polymorphic serialization in the scope of 'GrandParent'.
  Mark the base class as 'sealed' or register the serializer explicitly.
  </code></pre>
  <p>I am using ktor as wrapper, kotlin 1.5.10. I did this based on <a href="https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/polymorphism.md#registered-subclasses" rel="nofollow noreferrer">https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/polymorphism.md#registered-subclasses</a></p>
  <p>Any ideas?</p>