Why are contravariant type parameters in function parameters considered in “out” position?
问题 Hard for me to describe in english, but here's the issue: class Consumer<in T> { fun consume(t: T) {} } class Accepter<in T>() { // ERROR: Type parameter T is declared as 'in' but occurs in 'out' position in type Consumer<T> fun acceptWith(value: T, consumer: Consumer<T>) {} } It can be fixed like this: fun <U : T> acceptWith(value: T, consumer: Consumer<U>) {} But I don't understand the issue. It doesn't seem unsafe to allow Consumer<T> . Can someone explain this? 回答1: The argument position