// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JS_IR_ES6 // TODO: muted automatically, investigate should it be ran for JS or not // IGNORE_BACKEND: JS, NATIVE fun main(args: Array?) { val y: Unit = Unit //do not compile A() //do not compile C(Unit) //do not compile //do not compile System.out?.println(fff(Unit)) //do not compile System.out?.println(id(y)) //do not compile System.out?.println(fff(id(y)) == id(foreach(arrayOfNulls(0) as Array,{ e : Int -> }))) //do not compile } class A() class C(val value: T) { fun foo(): T = value } fun fff(x: T) : T { return x } fun id(value: T): T = value fun foreach(array: Array, action: (Int)-> Unit) { for (el in array) { action(el) //exception through compilation (see below) } } fun almostFilter(array: Array, action: (Int)-> Int) { for (el in array) { action(el) } } fun box() : String { val a = arrayOfNulls(3) as Array a[0] = 0 a[1] = 1 a[2] = 2 foreach(a, { el : Int -> System.out?.println(el) }) almostFilter(a, { el : Int -> el }) main(null) return "OK" }