Files
kotlin-fork/backend.native/tests/external/codegen/blackbox/functions/invoke/extensionInvokeOnExpr.kt
T
Ilya Matveev 1b553ebfaf backend/tests: Add blackbox tests from Kotlin JVM
Added tests from testData/codegen/box directory. There are blackbox tests
in other directories and they are to be added.
2017-01-20 14:04:04 +03:00

22 lines
491 B
Kotlin

class A
class B {
operator fun A.invoke() = "##"
operator fun A.invoke(i: Int) = "#${i}"
}
fun foo() = A()
fun B.test(): String {
if (A()() != "##") return "fail1"
if (A()(1) != "#1") return "fail2"
if (foo()() != "##") return "fail3"
if (foo()(42) != "#42") return "fail4"
if ((foo())(42) != "#42") return "fail5"
if ({ -> A()}()() != "##") return "fail6"
if ({ -> A()}()(37) != "#37") return "fail7"
return "OK"
}
fun box(): String = B().test()