Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

199
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda