From 056435a9e5e97fd0fb48c7361b0d374b46b687d5 Mon Sep 17 00:00:00 2001 From: Igor Chevdar Date: Fri, 28 Feb 2020 17:10:05 +0300 Subject: [PATCH] Fix for https://youtrack.jetbrains.com/issue/KT-36980 --- .../kotlin/backend/konan/llvm/IrToBitcode.kt | 6 +---- .../konan/lower/ReturnsInsertionLowering.kt | 18 +++++++++++---- backend.native/tests/build.gradle | 5 +++++ .../tests/codegen/inline/coercionToUnit.kt | 22 +++++++++++++++++++ 4 files changed, 42 insertions(+), 9 deletions(-) create mode 100644 backend.native/tests/codegen/inline/coercionToUnit.kt diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt index cf3045dad1f..f9f431794b4 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt @@ -1818,11 +1818,7 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map myRun(action: () -> T): T = action() + +fun foo(n: Number, b: Boolean) { + n.let { + if (b) return@let + + myRun() { 42 } + } +} + +@Test fun runTest() { + println(foo(42, false)) +}