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

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

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