interface IntConvertible { fun toInt(): Int } fun foo(init: Int, v: FooTP, l: Int.(FooTP) -> Int) = init.l(v) fun computeSum(array: Array) = foo(0, array) { var res = this for (element in it) res += element.toInt() res } class N(val v: Int) : IntConvertible { override fun toInt() = v } interface Grouping { fun keyOf(element: GroupingInputTP): GroupingOutputTP } fun groupingBy(keySelector: (Char) -> GroupingByTP): Grouping { fun foo(p0: T, p1: GroupingByTP) {} foo(0, keySelector('a')) class A(p0: T, p1: GroupingByTP) {} A(0, keySelector('a')) return object : Grouping { override fun keyOf(element: Char): GroupingByTP = keySelector(element) } } class Delft { fun getComparator(other: DelftTP) = { this == other } } fun box(): String { if (computeSum(arrayOf(N(2), N(14))) != 16) return "Fail1" if (groupingBy { it }.keyOf('A') != 'A') return "Fail2" return "OK" }