Is there a way to restrict a type parameter to be a data class, à la
Product for Scala case classes? I think the
Any in the construction, below, is redundant.
fun <T: Any> foo(...)
Also, given a
KClass, is there a way to figure out which constructor is the primary constructor (at least for a data class)? Perhaps it’s always the first one listed.
val ctor: Constructor<T> = kClass.constructors.first().javaConstructor!!