// !CHECK_TYPE package foo import checkType import checkSubtype fun Any.foo() : () -> Unit { return {} } fun Any.foo1() : (i : Int) -> Unit { return {} } fun foo2() : (i : () -> Unit) -> Unit { return {} } fun fooT1(t : T) : () -> T { return {t} } fun fooT2() : (t : T) -> T { return {it} } fun main(args : Array) { args.foo()() args.foo1()() a.foo1()() a.foo1()(a) args.foo1()(1) args.foo1()("1") a.foo1()("1") a.foo1()(a) foo2()({}) foo2(){} (foo2()){} (foo2()){x -> } foo2()({x -> }) val a = fooT1(1)() checkSubtype(a) val b = fooT2()(1) checkSubtype(b) fooT2()(1) // : Any? 1() 1{} 1(){} } fun f() : Int.() -> Unit = {} fun main1() { 1.(fun Int.() = 1)(); {1}(); (fun (x : Int) = x)(1) 1.(fun Int.(x : Int) = x)(1); l@{1}() 1.((fun Int.() = 1))() 1.(f())() 1.if(true){f()}else{f()}() 1.if(true)(fun Int.() {})else{f()}() 1."sdf"() 1."sdf" 1.{} 1.if (true) {} } fun test() { {x : Int -> 1}(); (fun Int.() = 1)() "sd".(fun Int.() = 1)() val i : Int? = null i.(fun Int.() = 1)(); {}() 1?.(fun Int.() = 1)() 1.{}() }