// !CHECK_TYPE package n import java.util.* import checkSubtype fun test() { val foo = arrayList("").map { it -> it.length }.fold(0, { x, y -> Math.max(x, y) }) checkSubtype(foo) checkSubtype(foo) } //from library fun arrayList(vararg values: T) : ArrayList {} fun Collection.map(transform : (T) -> R) : List {} fun Iterable.fold(initial: T, operation: (T, T) -> T): T {}