From bc37a87974dbfa0f96145f8524d952431fc98dd8 Mon Sep 17 00:00:00 2001 From: pyos Date: Fri, 20 Mar 2020 16:27:21 +0100 Subject: [PATCH] JVM_IR: produce better debug messages on inlining failures That's the only thing `compilationContextDescriptor` is used for; it clearly shouldn't point to the callee, but to the caller. --- .../jvm/codegen/IrSourceCompilerForInline.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrSourceCompilerForInline.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrSourceCompilerForInline.kt index ba33ac2a2a1..8819c92e977 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrSourceCompilerForInline.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrSourceCompilerForInline.kt @@ -28,7 +28,7 @@ import org.jetbrains.kotlin.ir.declarations.IrAttributeContainer import org.jetbrains.kotlin.ir.declarations.IrClass import org.jetbrains.kotlin.ir.declarations.IrDeclaration import org.jetbrains.kotlin.ir.declarations.IrFunction -import org.jetbrains.kotlin.ir.expressions.IrMemberAccessExpression +import org.jetbrains.kotlin.ir.expressions.IrFunctionAccessExpression import org.jetbrains.kotlin.ir.util.functions import org.jetbrains.kotlin.ir.util.isSuspend import org.jetbrains.kotlin.ir.util.parentAsClass @@ -46,7 +46,7 @@ import org.jetbrains.org.objectweb.asm.tree.MethodNode class IrSourceCompilerForInline( override val state: GenerationState, - override val callElement: IrMemberAccessExpression, + override val callElement: IrFunctionAccessExpression, private val callee: IrFunction, internal val codegen: ExpressionCodegen, private val data: BlockInfo @@ -78,7 +78,7 @@ class IrSourceCompilerForInline( get() = codegen.context.psiSourceManager.getKtFile(codegen.irFunction.fileParent) override val contextKind: OwnerKind - get() = OwnerKind.getMemberOwnerKind(callElement.symbol.descriptor.containingDeclaration!!) + get() = OwnerKind.getMemberOwnerKind(callElement.symbol.descriptor.containingDeclaration) override val inlineCallSiteInfo: InlineCallSiteInfo get() { @@ -118,9 +118,9 @@ class IrSourceCompilerForInline( } ?: callee else callee - val fakeCodegen = FakeClassCodegen(forInlineFunction, codegen.classCodegen) - val node = FunctionCodegen(forInlineFunction, fakeCodegen).generate() - return SMAPAndMethodNode(node, SMAP(fakeCodegen.getOrCreateSourceMapper().resultMappings)) + val classCodegen = FakeClassCodegen(forInlineFunction, codegen.classCodegen) + val node = FunctionCodegen(forInlineFunction, classCodegen).generate() + return SMAPAndMethodNode(node, SMAP(classCodegen.getOrCreateSourceMapper().resultMappings)) } override fun hasFinallyBlocks() = data.hasFinallyBlocks() @@ -148,10 +148,10 @@ class IrSourceCompilerForInline( } override val compilationContextDescriptor: DeclarationDescriptor - get() = callElement.symbol.descriptor + get() = compilationContextFunctionDescriptor override val compilationContextFunctionDescriptor: FunctionDescriptor - get() = callElement.symbol.descriptor as FunctionDescriptor + get() = generateSequence(codegen) { it.inlinedInto }.last().irFunction.descriptor override fun getContextLabels(): Set { val name = codegen.irFunction.name.asString()