[IR] Adopted KotlinNothingValueExceptionLowering

This commit is contained in:
Igor Chevdar
2020-04-30 19:43:42 +05:00
parent 23d38bddaa
commit 73fc92a2b5
4 changed files with 14 additions and 0 deletions
@@ -171,6 +171,12 @@ internal val stringConcatenationPhase = makeKonanFileLoweringPhase(
description = "String concatenation lowering" description = "String concatenation lowering"
) )
internal val kotlinNothingValueExceptionPhase = makeKonanFileLoweringPhase(
::KotlinNothingValueExceptionLowering,
name = "KotlinNothingValueException",
description = "Throw proper exception for calls returning value of type 'kotlin.Nothing'"
)
internal val enumConstructorsPhase = makeKonanFileLoweringPhase( internal val enumConstructorsPhase = makeKonanFileLoweringPhase(
::EnumConstructorsLowering, ::EnumConstructorsLowering,
name = "EnumConstructors", name = "EnumConstructors",
@@ -355,6 +355,7 @@ internal val allLoweringsPhase = namedIrModulePhase(
typeOperatorPhase then typeOperatorPhase then
bridgesPhase then bridgesPhase then
autoboxPhase then autoboxPhase then
kotlinNothingValueExceptionPhase then
returnsInsertionPhase returnsInsertionPhase
), ),
actions = setOf(defaultDumper, ::moduleValidationCallback) actions = setOf(defaultDumper, ::moduleValidationCallback)
@@ -260,6 +260,8 @@ internal class KonanSymbols(
override val ThrowTypeCastException = internalFunction("ThrowTypeCastException") override val ThrowTypeCastException = internalFunction("ThrowTypeCastException")
override val ThrowKotlinNothingValueException = internalFunction("ThrowKotlinNothingValueException")
val throwClassCastException = internalFunction("ThrowClassCastException") val throwClassCastException = internalFunction("ThrowClassCastException")
val throwInvalidReceiverTypeException = internalFunction("ThrowInvalidReceiverTypeException") val throwInvalidReceiverTypeException = internalFunction("ThrowInvalidReceiverTypeException")
@@ -34,6 +34,11 @@ fun ThrowTypeCastException(): Nothing {
throw TypeCastException() throw TypeCastException()
} }
@ExportForCppRuntime
fun ThrowKotlinNothingValueException(): Nothing {
throw KotlinNothingValueException()
}
@ExportForCppRuntime @ExportForCppRuntime
fun ThrowInvalidReceiverTypeException(klass: KClass<*>): Nothing { fun ThrowInvalidReceiverTypeException(klass: KClass<*>): Nothing {
throw RuntimeException("Unexpected receiver type: " + (klass.qualifiedName ?: "noname")) throw RuntimeException("Unexpected receiver type: " + (klass.qualifiedName ?: "noname"))