Sure, it’s needed in number of cases, for example:...
# announcements
o
Sure, it’s needed in number of cases, for example:
Copy code
interface ReadOnlyContainer<out T> {
    fun get() : T // ok
    fun contains(value : @UnsafeVariance T) : Boolean // needs unsafe variance
}
It’s indeed unsafe, but it can be ok if you never send received
value
to outside of the class, where someone can interpret it as unrelated type. Normally, not storing it in the fields/arrays is enough, but if you are really clever, avoid sending such value to the lambda of type
(T)->Unit
stored in state as well.