https://kotlinlang.org logo
r

robstoll

03/20/2018, 11:20 AM
I want to write an extension function for list like this:
fun <T> List<T>.foo(t: T)
Is there a way to force that a consumer of this function cannot inadvertently kind of widen the type to Any (which is fine due to
List<out T>
). Or in other words, I would like to prevent the following:
listOf(1).foo("bla")