[JVM_IR] Keep track of catch variable gaps.

This ensures that catch variables are not visible in duplicated
finally blocks generated at an exit within the catch variable
scope.

^KT-46449 Fixed
This commit is contained in:
Mads Ager
2021-06-14 13:16:41 +02:00
committed by max-kammerer
parent 6aba6ea670
commit ae03e2983d
5 changed files with 15 additions and 18 deletions
@@ -1159,18 +1159,17 @@ class ExpressionCodegen(
val afterStore = markNewLabel()
val catchBody = clause.result
val catchResult = catchBody.accept(this, data)
var catchBlockInfo = BlockInfo(data)
catchBlockInfo.variables.add(VariableInfo(parameter, index, descriptorType, afterStore))
val catchResult = catchBody.accept(this, catchBlockInfo)
if (savedValue != null) {
catchResult.materializeAt(tryAsmType, aTry.type, true)
mv.store(savedValue, tryAsmType)
} else {
catchResult.discard()
}
frameMap.leave(clause.catchParameter)
val clauseEnd = markNewLabel()
mv.visitLocalVariable(parameter.name.asString(), descriptorType.descriptor, null, afterStore, clauseEnd, index)
writeLocalVariablesInTable(catchBlockInfo, markNewLabel())
if (tryInfo is TryWithFinallyInfo) {
data.handleBlock { genFinallyBlock(tryInfo, tryCatchBlockEnd, null, data) }