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

498
Views
How to solve 2nd level inheritance with generic classes?

I'm implementing an MVP architecture in Kotlin and Android Studio shows no error, however it doesn't compile:

java.lang.AssertionError: resultingDescriptor shouldn't be null: candidateDescriptor: constructor BasePresenter(view: View) defined in com.exmaple.base.BasePresenter substitution: org.jetbrains.kotlin.types.IndexedParametersSubstitution@70144d7e at org.jetbrains.kotlin.resolve.calls.model.ResolvedCallImpl.setResultingSubstitutor(ResolvedCallImpl.java:205) ....

Is it possible to use the ConcreteView / ConcretePresenter in the middle of inheritance?

code:

/**
 * These are the base classes
 */
interface MvpView

interface BaseView<Presenter : BasePresenter<*>> : MvpView, HasMvpView<MvpView>

// to avoid circular dependency
interface HasMvpView<View : MvpView> 

abstract class BaseMvpActivity<Presenter : BasePresenter<*>> : AppCompatActivity(), HasMvpView<MvpView>

abstract class BaseMvpFragment<Activity : BaseMvpActivity<*>, Presenter : BasePresenter<*>>: Fragment(), HasMvpView<MvpView> {
        // this will cause the error
        abstract var presenter: Presenter
}


/**
 * There's a Viewpager, and each page looks the same the only difference is their source of data. That's why I tried implementing another level of abstraction over the base classes
 */
interface CategoryPagerView<Presenter: BasePresenter<*>> : BaseView<Presenter>

abstract class CategoryPagerFragment: BaseMvpFragment<LandingActivity, BasePresenter<*>>()

/**
 * A concrete type of the Viewpager's fragment, its presenter and the view
 */
interface ConcreteView : CategoryPagerView<ConcretePresenter> 

class ConcretePresenter(view: ConcreteView) : BasePresenter<*>(view)

class ConcreteFragment : CategoryPagerFragment(), ConcreteView {
        // this line shows no error in the IDE, but in compile time
        override var presenter = ConcretePresenter(this)

Thanks for your help!

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

It's an internal assertion error thrown by the compiler. You can see the compiler source code where this is thrown:

https://github.com/JetBrains/kotlin/blob/master/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/ResolvedCallImpl.java

Apparently the resultingDescriptor is null at a point where it should never be null. So it seems like a compiler bug. Maybe it should be rewritten in Kotlin to avoid issues with null :)

Please file a bug report at https://youtrack.jetbrains.com/issues/KT

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!