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

381
Visualizações
Kotlin variable names: case sensitive?

Kotlin language spec claims identifiers are case-sensitive yet the following produces compiler error messages because of apparently case-insensitive generated getters/setters.

var a=10; var A=20

Clash.kt:1:1: error: platform declaration clash: The following declarations have the same JVM signature (getA()I):
    fun <get-A>(): Int defined in root package
    fun <get-a>(): Int defined in root package
var a=10
^

I understand what is happening but does this seem like the right behavior? Is there a way around this?

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

This has to do with how the compiler creates getters and setters to match the Java Beans standard. In this case, both of the getters and setters are named getA() and setA(...) because it tries to use the initial caps version of the field. If these fields were named aa and AA, however, you'd have getAa() and getAA() and wouldn't have a name collision.

over 4 years ago · Santiago Trujillo Relatório

0

An alternative workaround is to use @JvmField on one or both of the properties. This prevents Java getter and setter methods from being generated, so there are no clashing method signatures to worry about.

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