Class delegation to generic


#1

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


#2

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.