[Wasm] Fix generation optimised when expression with Nothing type

Fixed #KT-62147
This commit is contained in:
Igor Yakovlev
2023-09-22 14:19:45 +02:00
parent 624d35fefd
commit 758484a01f
19 changed files with 146 additions and 3 deletions
@@ -329,7 +329,10 @@ private fun BodyGenerator.genTableIntSwitch(
body.buildBlock(resultType)
}
resultType?.let { generateDefaultInitializerForType(it, body) } //stub value
if (resultType != null && resultType !is WasmUnreachableType) {
generateDefaultInitializerForType(resultType, body) //stub value
}
body.buildGetLocal(selectorLocal, location)
if (shift != 0) {
body.buildConstI32(shift, location)
@@ -344,7 +347,7 @@ private fun BodyGenerator.genTableIntSwitch(
body.buildEnd()
for (expression in branches) {
if (resultType != null) {
if (resultType != null && resultType !is WasmUnreachableType) {
body.buildDrop(location)
}
generateWithExpectedType(expression.expression, expectedType)
@@ -354,7 +357,7 @@ private fun BodyGenerator.genTableIntSwitch(
}
if (elseExpression != null) {
if (resultType != null) {
if (resultType != null && resultType !is WasmUnreachableType) {
body.buildDrop(location)
}
generateWithExpectedType(elseExpression, expectedType)