<@U0JKURZHA> Well, it depends. You're dealing with...
# announcements
o
@renatoathaydes Well, it depends. You're dealing with a Class instance, so you're touching on the topic of reflection. Effectively, you won't get much help from the compiler. You could use reflection to get the field named
INSTANCE
and get its value:
Copy code
fun main(args: Array<String>) {
	val cls: Class<out A> = A.B::class.java
	val a: A = cls.getField("INSTANCE").get(null) as A
	a.abc()
}

sealed class A {
	abstract fun abc()
	
	object B : A() {
		override fun abc() {
			println("Hello")
		}
	}
}
One problem here, though, is that if the Class<out A> variable actually refers to A's class instance, then you'll get an exception.