Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

202
Vistas
How to obtain superclass of a reflected class in Kotlin?

If Kotlin disallows multiple inheritance, then why KClass<*>.superclasses return a list? How to find that single superclass?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

According to the documentation, superclasses contains immediate superclasses of this class, in the order they are listed in the source code. Includes superclasses and superinterfaces of the class, but does not include the class itself.

A Kotlin class may in fact only inherit from a single super class, but may implement several super interfaces.

Borrowing from a different question / answer on StackOverflow, something like the following might work. However, I did not test this.

val KClass<*>.isInterface: Boolean
    get() = java.isInterface

val KClass<*>.superclass: KClass<*> 
    get() = superclasses.filterNot { it.isInterface }.single()
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda