From 26bd3bfe6bb5bca589b896d1873e604f1e7504e4 Mon Sep 17 00:00:00 2001 From: Vasily Levchenko Date: Wed, 18 Sep 2019 15:45:37 +0300 Subject: [PATCH] [codegen] make generated reified inline function's bodies throwing k.IllegalStateException --- .../src/org/jetbrains/kotlin/backend/konan/ir/Ir.kt | 1 + .../jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt | 10 ++++++++-- .../main/kotlin/kotlin/native/internal/RuntimeUtils.kt | 6 ++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/Ir.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/Ir.kt index a4879cebbde..8f8d4f7567d 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/Ir.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/Ir.kt @@ -229,6 +229,7 @@ internal class KonanSymbols( val throwInvalidReceiverTypeException = internalFunction("ThrowInvalidReceiverTypeException") val throwIllegalStateException = internalFunction("ThrowIllegalStateException") + val throwIllegalStateExceptionWithMessage = internalFunction("ThrowIllegalStateExceptionWithMessage") override val ThrowUninitializedPropertyAccessException = internalFunction("ThrowUninitializedPropertyAccessException") 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 7c80587eb04..b67541b162d 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 @@ -675,8 +675,7 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map body.statements.forEach { generateStatement(it) } is IrExpressionBody -> generateStatement(body.expression) diff --git a/runtime/src/main/kotlin/kotlin/native/internal/RuntimeUtils.kt b/runtime/src/main/kotlin/kotlin/native/internal/RuntimeUtils.kt index fd5df9706be..24fbd80a50d 100644 --- a/runtime/src/main/kotlin/kotlin/native/internal/RuntimeUtils.kt +++ b/runtime/src/main/kotlin/kotlin/native/internal/RuntimeUtils.kt @@ -66,6 +66,12 @@ internal fun ThrowIllegalStateException() : Nothing { throw IllegalStateException() } +@ExportForCppRuntime +internal fun ThrowIllegalStateExceptionWithMessage(message:String) : Nothing { + throw IllegalStateException(message) +} + + @ExportForCppRuntime internal fun ThrowNotImplementedError(): Nothing { throw NotImplementedError("An operation is not implemented.")