[codegen] make generated reified inline function's bodies throwing k.IllegalStateException

This commit is contained in:
Vasily Levchenko
2019-09-18 15:45:37 +03:00
parent c8252693d6
commit 26bd3bfe6b
3 changed files with 15 additions and 2 deletions
@@ -229,6 +229,7 @@ internal class KonanSymbols(
val throwInvalidReceiverTypeException = internalFunction("ThrowInvalidReceiverTypeException")
val throwIllegalStateException = internalFunction("ThrowIllegalStateException")
val throwIllegalStateExceptionWithMessage = internalFunction("ThrowIllegalStateExceptionWithMessage")
override val ThrowUninitializedPropertyAccessException = internalFunction("ThrowUninitializedPropertyAccessException")
@@ -675,8 +675,7 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
if ((declaration as? IrSimpleFunction)?.modality == Modality.ABSTRACT
|| declaration.isExternal
|| body == null
|| declaration.isReifiedInline)
|| body == null)
return
generateFunction(codegen, declaration,
@@ -687,6 +686,13 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
using(parameterScope) {
using(VariableScope()) {
recordCoverage(body)
if (declaration.isReifiedInline) {
callDirect(context.ir.symbols.throwIllegalStateExceptionWithMessage.owner,
listOf(context.llvm.staticData.kotlinStringLiteral(
"unsupported call of reified inlined function `${declaration.fqNameForIrSerialization}`").llvm),
Lifetime.IRRELEVANT)
return@using
}
when (body) {
is IrBlockBody -> body.statements.forEach { generateStatement(it) }
is IrExpressionBody -> generateStatement(body.expression)
@@ -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.")