title: Tell Kotlin that a generic type is an interface
body: <p>Let's say I have a class <code>Foo</code></p>
  <pre><code>class Foo {
      val noProblem = &quot;Hakuna Matata&quot;
  }
  </code></pre>
  <p>I now want to decorate it with an ID. Kotlin's delegates make this relatively painless:</p>
  <pre><code>class IdentifiableFoo(
      val id: Int,
      foo: Foo,
  ): Foo by foo
  
  interface Foo {
      val noProblem: String
  }
  class FooImpl: Foo {
      override val noProblem = &quot;Hakuna Matata&quot;
  }
  </code></pre>
  <p>but let's say I have another class <code>Bar</code> that I also want to decorate, and then another <code>Baz</code>, and then another ...</p>
  <p>I could just create a <code>IdentifiableXYZ</code> for each of them, of course.</p>
  <p>But what I really want is something akin to</p>
  <pre><code>class Identifiable&lt;T&gt; (
      val id: Int,
      thing: T
  ): T by thing
  </code></pre>
  <p>That I could just use for all of them.</p>
  <p>And yes, there's a very good chance that the language doesn't support something like that, but the error message made me think:</p>
  <blockquote>
  <p>Only classes and interfaces may serve as supertypes</p>
  </blockquote>
  <p>so can I do some <code>where</code> magic or something to tell Kotlin that <code>T</code> is required to be an interface?</p>