[K/N] Fix debug info for lambdas inside inline functions

^KT-57365
This commit is contained in:
Pavel Kunyavskiy
2023-08-10 11:50:22 +02:00
committed by Space Team
parent dc3641f79d
commit eefc51657a
6 changed files with 25 additions and 16 deletions
@@ -813,15 +813,22 @@ internal class CodeGeneratorVisitor(
if (!declaration.shouldGenerateBody())
return
// Some special functions may have empty body, thay are handled separetely.
val body = declaration.body ?: return
val file = if (declaration.origin != IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA)
null
else ((declaration as? IrSimpleFunction)?.attributeOwnerId as? IrSimpleFunction)?.let { context.irLinker.getFileOf(it) }?.takeIf {
(currentCodeContext.fileScope() as FileScope).file != it
val file = run {
val original = (declaration as? IrSimpleFunction)?.attributeOwnerId ?: return@run null
val originalFunction = when (original) {
is IrFunctionExpression -> original.function
is IrFunction -> original
else -> return@run null
}
context.irLinker.getFileOf(originalFunction)
}
val scope = file?.let {
FileScope(it)
val scope = if (file != null && file != (currentCodeContext.fileScope() as FileScope).file) {
FileScope(file)
} else {
null
}
using(scope) {
generateFunction(codegen, declaration,
@@ -70,6 +70,7 @@ internal class BridgesSupport(mapping: NativeMapping, val irBuiltIns: IrBuiltIns
returnType = bridgeDirections.returnDirection.type() ?: function.returnType
isSuspend = function.isSuspend
}.apply {
attributeOwnerId = function.attributeOwnerId
parent = function.parent
val bridge = this
@@ -542,6 +542,7 @@ internal class FunctionReferenceLowering(val generationState: NativeGenerationSt
returnType = functionReturnType
isSuspend = superFunction.isSuspend
}.apply {
attributeOwnerId = functionReference.attributeOwnerId
val function = this
function.createDispatchReceiverParameter()