title: Generic constraint for "data" class objects
body: <p>I would like to semantically constrain a map to only accept "data" class object types as the value in kotlin like so:</p>
  
  <pre><code>class Test(
      val test : Int
  )
  
  data class Test2 (
      val test : Int
  )
  
  fun test(map : Map&lt;String, /* compile error on Test, but accept Test2 or any other data class */&gt;) {
  }
  </code></pre>
  
  <p>I'm mainly trying to do this so that I can keep everything in the map cloneable, but when I do this:</p>
  
  <pre><code>fun &lt;T: Cloneable&gt; test(map : Map&lt;String, T&gt;) {
       // test clone
       map.map { it.key.uuid to it.value.clone() } .toMap() // error on .clone() Cannot access 'clone': it is protected in 'Cloneable'
  }
  </code></pre>
  
  <p>but I thought implementing the <code>Cloneable</code> interface made your clone method public? Essentially I'm looking for a compile time guarantee that all data is copyable in that method invocation, (is a primitive type, a data class that I can call <code>.copy()</code> on, or any object that has implemented <code>Cloneable</code>). Is my only option reflection and runtime assertions?</p>