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
List<? extends Something > is generated instead of List<Something>

I have a service call that returns a JSON response which is then passed through a data manager that transforms the data if service is success or creates an error body if the call is a failure.

The data manager is written in kotlin and the particular line of code i am interested in is this

val mutableList = mutableListOf<Address>()
return Result.error(errorTransformation(serviceErrors, mutableList))

My errorTransformation class is basically an Exception call and this is written java. The constructor for the exception class is

ExceptionClass(ServiceErrors serviceError ,List<Address> address){
    // initiialize fields here
}

Now When i try to initialize my exception class it says appropriate constructor is found and it is showing me a suggestion to generate one with syntax

ExceptionClass(ServiceErrors serviceError ,List<? extends Address> address){
    // initiialize fields here
}

Why is this happening? I only want List<Address>, not List<? extends Address>.

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

0

It's kotlin specific behavior to implicitly use List<? extends Address> instead of List<Address>. You can force kotlin generate exactly what you need using @JvmSuppressWildcards annotation

val mutableList = mutableListOf<@JvmSuppressWildcards Address>()
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