Gilles Barbier
10/09/2024, 5:21 PMimport kotlinx.coroutines.channels.Channel
class Box<out M>(
// ...
)
interface Transport<S> {
// ...
}
interface Message {
// ...
}
fun <T : Message> test(
consumer: Transport<T>,
channel: Channel<Box<T>> = Channel()
): Channel<Box<T>> {
return channel
}
fun main() {
lateinit var consumer: Transport<out Message> // just to get the right type
var c = test(consumer)
}
Here the IDE (IntelliJ) does not see any issue. But If I ask IntelliJ to provide the type, I got:
var c: Channel<Box<Message>> = test(consumer)
But then IntelliJ itself tells me it's wrong and should be:
var c: Channel<out Box<Message>> = test(consumer)
At last, for both type, the can not provide it to the test
function - IntelliJ tells me it's not the right type
val c: Channel<out Box<Message>> = Channel()
test(consumer, c)
Any hint would be greatly appreciated!CLOVIS
10/11/2024, 7:08 AM