Projections are not allowed for immediate supertype subtypes.

I have an abstract class as follows:

abstract class AbstractSync<out C : Configuration<*>> : ISync {
    internal abstract val configuration: C
    ...
}

I need another abstract class that inherits from this:

abstract class CascadedSync : AbstractSync {}

The CascadedSync class should not change the general parameter C, it should, in fact, implement only one ISync method and nothing else.

I am trying to use different syntaxes to achieve this seemingly simple task. In Java, it would look like this:

abstract class CascadedSync extends AbstractSync {    
}

Translating it to Kotlin using IntelliJ produces this:

abstract class CascadedSync : AbstractSync<*>()

But at the same time gives the following error:

forecasts are not allowed for immediate supertype subtypes

What is the correct syntax?

+4
source share
1 answer

Kotlin, Java, , :

abstract class CascadedSync<out C : Configuration<*>> : AbstractSync<C>() {
    // ...
}
+6

Source: https://habr.com/ru/post/1664095/


All Articles