From 295f71a29cfb35d7b2bf662f92ccaaf8e01de774 Mon Sep 17 00:00:00 2001 From: Igor Chevdar Date: Sun, 21 Jan 2018 23:28:19 +0300 Subject: [PATCH] Fixed inline call arguments evaluation + test --- .../backend/konan/lower/FunctionInlining.kt | 4 ++-- backend.native/tests/build.gradle | 5 +++++ .../tests/codegen/inline/lambdaInDefaultValue.kt | 15 +++++++++++++++ samples/globalState/src/main/kotlin/Global.kt | 2 +- 4 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 backend.native/tests/codegen/inline/lambdaInDefaultValue.kt diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/FunctionInlining.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/FunctionInlining.kt index ecde64e6e67..8f2c6d66f19 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/FunctionInlining.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/FunctionInlining.kt @@ -125,13 +125,13 @@ private class Inliner(val globalSubstituteMap: MutableMap String = { it }): String { + return lambda(param) +} + +fun box(): String { + return inlineFun("OK") +} + +@Test fun runTest() { + println(box()) +} \ No newline at end of file diff --git a/samples/globalState/src/main/kotlin/Global.kt b/samples/globalState/src/main/kotlin/Global.kt index 64fce7ac530..6a0edaf4c78 100644 --- a/samples/globalState/src/main/kotlin/Global.kt +++ b/samples/globalState/src/main/kotlin/Global.kt @@ -18,7 +18,7 @@ import global.* import kotlinx.cinterop.* import platform.posix.* -fun Int.ensureUnixCallResult(op: String, predicate: (Int) -> Boolean = { x -> x == 0} ): Int { +inline fun Int.ensureUnixCallResult(op: String, predicate: (Int) -> Boolean = { x -> x == 0} ): Int { if (!predicate(this)) { throw Error("$op: ${strerror(posix_errno())!!.toKString()}") }