JVM: remove TypedNullValue, hack interpreter instead

This commit is contained in:
pyos
2022-05-10 16:38:39 +02:00
committed by teamcity
parent 513ef575ce
commit 0fc676a20c
5 changed files with 13 additions and 39 deletions
@@ -657,18 +657,6 @@ class ExpressionCodegen(
val value = initializer.accept(this, data)
initializer.markLineNumber(startOffset = true)
value.materializeAt(varType, declaration.type)
// We need to generate CHECKCAST from ACONST_NULL here for coroutines,
// since otherwise, upon spilling and then unspilling, we will get VerifyError,
// because state-machine builder does not know the type of the ACONST_NULL
// and assumes it to be Ljava/lang/Object;, which is incorrect.
// Generating CHECKCAST hints the state-machine builder the type of the variable
// avoiding the issue of VerifyError. See KT-51718
// Exception is Ljava/lang/Object;, since CHECKCAST Ljava/lang/Object; is effectively no-op.
if (initializer.isNullConst() && varType != OBJECT_TYPE &&
(irFunction.isSuspend || irFunction.isInvokeSuspendOfLambda())
) {
mv.checkcast(varType)
}
declaration.markLineNumber(startOffset = true)
mv.store(index, varType)
} else if (declaration.isVisibleInLVT) {