title: Kotlin - Using data class with type from an interface
body: <p>I have an <code>overrides</code> interface which I created in order to combine 2 data classes - like so:</p>
  
  <pre><code>interface Overrides
  
  data class SoOverrides(
      val soId: String,
      val freeInterval: String?
  ) : Overrides
  
  data class CoOverrides(
      val coId: String,
      val pubType: String,
  ) : Overrides
  </code></pre>
  
  <p>I'm then trying to set the type of an item in my main data class to <code>Overrides</code> like so:</p>
  
  <pre><code>@Document(collection = Campaign.COLLECTION)
  data class Campaign(
      @Id
      val id: String,
      val title: String,
      val overrides: List&lt;Overrides&gt;? = null
  ) {
      companion object {
          const val COLLECTION: String = "campaigns"
      }
  }
  </code></pre>
  
  <p>However whenever I go to run this, I get the error:</p>
  
  <pre><code>Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [co.....models.Overrides]: Specified class is an interface
  </code></pre>
  
  <p>Could someone please explain what I need to do to use that type <code>Overrides</code>. I'm extending the interface that way so I can have multiple classes, under one name, but not sure why it doesnt work?</p>
  
  <p>I guess I could just use <code>val overrides: List&lt;*&gt;? = null</code></p>
  
  <p>Any help appreciated.</p>
  
  <p>Thanks.</p>