Hello guys! Is there a way to get a companion obje...
# announcements
f
Hello guys! Is there a way to get a companion objects parent class from within a companion declaration?
d
What doy ou mean by "within a companion declaration"? Can you give an example?
f
my example i have a class called Game with an companion object. type: Game.Companion i want to get the Game class not the Game.Companion
d
I don't think it's implemented in Kotlin reflection, but you can do this:
Copy code
val companionClass = Game.Companion::class.java
val parentClass = companionClass.declaringClass // Game class
f
awesome will test this