Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumKotlingenerics variance in outSingle-choice MCQ

With this declaration-site covariant class, why does passing `b` to `printAll` compile without any use-site projection?

class Source<out T>(private val items: List<T>) { fun get(i: Int): T = items[i] val size: Int get() = items.size } fun printAll(s: Source<Any>) { for (i in 0 until s.size) println(s.get(i)) } fun caller(b: Source<String>) = printAll(b)