Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

190
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!