# Class delegation to generic

**URL:** <https://discuss.kotlinlang.org/t/class-delegation-to-generic/4681>\
**Category:** Uncategorized\
**Created:** [September 21, 2017, 12:38pm UTC](https://discuss.kotlinlang.org/t/class-delegation-to-generic/4681 "2017-09-21T12:38:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![roaanv](https://avatars.discourse-cdn.com/v4/letter/r/6f9a4e/32.png) [@roaanv](https://discuss.kotlinlang.org/u/roaanv)\
**Post date:** [September 21, 2017, 12:38pm UTC](https://discuss.kotlinlang.org/t/class-delegation-to-generic/4681/1 "2017-09-21T12:38:47Z")

</div>

I’d like to use class delegation to a generic interface, something like the following  
class SomeClass (impl: T) : T by impl

The problem with this as is, is that the compiler says “Only classes and interfaces my service as supertypes”.  
How can I specify that T is constrained to an interface or class

---

<div class="post-metadata">

**Author:** ![yole](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/yole/32/1425_2.png) [@yole](https://discuss.kotlinlang.org/u/yole)\
**Post date:** [September 21, 2017, 2:28pm UTC](https://discuss.kotlinlang.org/t/class-delegation-to-generic/4681/2 "2017-09-21T14:28:43Z")

</div>

You cannot create a class which has a type parameter as a superclass, regardless of whether you’re using delegation or not. Such a class cannot be represented on the JVM.
