[JVM_IR] Properly handle inlined local var located in regenerated object
#KT-58778
This commit is contained in:
+10
-10
@@ -422,8 +422,16 @@ class ExpressionCodegen(
|
||||
}
|
||||
}
|
||||
|
||||
if (expression is IrInlinedFunctionBlock && expression.isFunctionInlining()) {
|
||||
markLineNumberAfterInlineIfNeeded(isInsideCondition)
|
||||
if (expression is IrInlinedFunctionBlock) {
|
||||
// This block must be executed after `writeLocalVariablesInTable`
|
||||
if (expression.isFunctionInlining()) {
|
||||
val callLineNumber = lineNumberMapper.getLineNumberForOffset(expression.inlineCall.startOffset)
|
||||
// takeUnless is required to avoid markLineNumberAfterInlineIfNeeded for inline only
|
||||
lastLineNumber = callLineNumber.takeUnless { noLineNumberScope } ?: -1
|
||||
markLineNumberAfterInlineIfNeeded(isInsideCondition)
|
||||
} else {
|
||||
lineNumberMapper.setUpAdditionalLineNumbersAfterLambdaInlining(expression)
|
||||
}
|
||||
}
|
||||
|
||||
if (isSynthesizedInitBlock) {
|
||||
@@ -482,7 +490,6 @@ class ExpressionCodegen(
|
||||
private fun visitInlinedFunctionBlock(inlinedBlock: IrInlinedFunctionBlock, data: BlockInfo): PromisedValue {
|
||||
val inlineCall = inlinedBlock.inlineCall
|
||||
val callee = inlinedBlock.inlineDeclaration as? IrFunction
|
||||
val callLineNumber = lineNumberMapper.getLineNumberForOffset(inlineCall.startOffset)
|
||||
|
||||
// 1. Evaluate NON DEFAULT arguments from inline function call
|
||||
inlinedBlock.getNonDefaultAdditionalStatementsFromInlinedBlock().forEach { exp ->
|
||||
@@ -539,13 +546,6 @@ class ExpressionCodegen(
|
||||
|
||||
lineNumberMapper.dropCurrentSmap()
|
||||
|
||||
if (inlinedBlock.isLambdaInlining()) {
|
||||
lineNumberMapper.setUpAdditionalLineNumbersAfterLambdaInlining(inlinedBlock)
|
||||
} else {
|
||||
// takeUnless is required to avoid markLineNumberAfterInlineIfNeeded for inline only
|
||||
lastLineNumber = callLineNumber.takeUnless { noLineNumberScope } ?: -1
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
+8
@@ -123,6 +123,14 @@ private class LocalVariablesProcessor : IrElementVisitor<Unit, LocalVariablesPro
|
||||
element.acceptChildren(this, data)
|
||||
}
|
||||
|
||||
override fun visitClass(declaration: IrClass, data: Data) {
|
||||
if (declaration.originalBeforeInline != null) {
|
||||
// Don't take into account regenerated classes
|
||||
return super.visitClass(declaration, data.copy(processingOriginalDeclarations = false))
|
||||
}
|
||||
super.visitClass(declaration, data)
|
||||
}
|
||||
|
||||
override fun visitBlock(expression: IrBlock, data: Data) {
|
||||
if (expression !is IrInlinedFunctionBlock) {
|
||||
return super.visitBlock(expression, data)
|
||||
|
||||
Reference in New Issue
Block a user