JVM_IR KT-43242 generate switch subject as primitive 'int'

This commit is contained in:
Dmitry Petrov
2020-11-19 12:08:48 +03:00
parent 05ddbeab0a
commit 118a7d4e34
6 changed files with 51 additions and 1 deletions
@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.ir.types.*
import org.jetbrains.kotlin.ir.util.dump
import org.jetbrains.kotlin.ir.util.isTrueConst
import org.jetbrains.org.objectweb.asm.Label
import org.jetbrains.org.objectweb.asm.Type
import java.util.*
// TODO: eliminate the temporary variable
@@ -367,7 +368,8 @@ class SwitchGenerator(private val expression: IrWhen, private val data: BlockInf
// information for the subject as the `when` line number has already been
// emitted.
codegen.noLineNumberScope {
subject.accept(codegen, data).materialize()
val subjectValue = subject.accept(codegen, data)
subjectValue.materializeAt(Type.INT_TYPE, subjectValue.irType)
}
genIntSwitch(cases)
}