The problem with inability to call getSuperclass() on variable with type Class<*> is a bug. I have already posted it to tracker:KT-3194. An issue doesn't mention java.lang.Class, but emulates the situation with pure kotlin.
As a workaround you can explicitly convert your clsvariable to Class<Any>:
``
fun inspect(cls : Class<*>?, indent : Int = 0) {
if (cls == null) return
// …
inspect((cls as Class<Any>).getSuperclass(), indent + 2)
}
The explicit cast works, but compiler will spit a warn:
Unchecked cast: java.lang.Class<out jet.Any?>? to java.lang.Class<jet.Any>
How do I properly cast without the warning? (I tried "Class<Any?>" and I get the same WARN.)
Interestingly if I cast it as “Class<out Any?>”, I will also get the “Unresolved reference getSuperclasss()” error! I hope this helps your bug ticket in doing more through testing.