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

200
Vistas
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 Respuestas
Responde la pregunta

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 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