JVM_IR: pass callee after fake override resolution to source inliner

Fixes NPE in:

    open class A {
        inline fun f() = 1
    }

    class B : A() {
        fun g() = f()
    }
This commit is contained in:
pyos
2019-09-02 10:46:22 +02:00
committed by max-kammerer
parent 07bde889b4
commit 4ea4bc1c2b
2 changed files with 5 additions and 6 deletions
@@ -989,7 +989,7 @@ class ExpressionCodegen(
val original = (callee as? IrSimpleFunction)?.resolveFakeOverride() ?: irFunction
val methodOwner = callee.parent.safeAs<IrClass>()?.let(typeMapper::mapClass) ?: MethodSignatureMapper.FAKE_OWNER_TYPE
val sourceCompiler = IrSourceCompilerForInline(state, element, this, data)
val sourceCompiler = IrSourceCompilerForInline(state, element, original, this, data)
val reifiedTypeInliner = ReifiedTypeInliner(mappings, object : ReifiedTypeInliner.IntrinsicsSupport<IrType> {
override fun putClassInstance(v: InstructionAdapter, type: IrType) {
@@ -21,7 +21,6 @@ import org.jetbrains.kotlin.incremental.components.LookupLocation
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
import org.jetbrains.kotlin.ir.declarations.IrClass
import org.jetbrains.kotlin.ir.declarations.IrFunction
import org.jetbrains.kotlin.ir.expressions.IrCall
import org.jetbrains.kotlin.ir.expressions.IrMemberAccessExpression
import org.jetbrains.kotlin.ir.util.parentAsClass
import org.jetbrains.kotlin.ir.util.render
@@ -37,6 +36,7 @@ import org.jetbrains.org.objectweb.asm.tree.MethodNode
class IrSourceCompilerForInline(
override val state: GenerationState,
override val callElement: IrMemberAccessExpression,
private val callee: IrFunction,
private val codegen: ExpressionCodegen,
private val data: BlockInfo
) : SourceCompilerForInline {
@@ -94,15 +94,14 @@ class IrSourceCompilerForInline(
callDefault: Boolean,
asmMethod: Method
): SMAPAndMethodNode {
assert(callableDescriptor == callElement.descriptor.original) { "Expected $callableDescriptor got ${callElement.descriptor.original}" }
assert(callableDescriptor == callee.descriptor.original) { "Expected $callableDescriptor got ${callee.descriptor.original}" }
assert(codegen.lastLineNumber >= 0) { "lastLineNumber shall be not negative, but is ${codegen.lastLineNumber}" }
val irFunction = getFunctionToInline(callElement as IrCall, jvmSignature, callDefault)
val irFunction = getFunctionToInline(jvmSignature, callDefault)
return makeInlineNode(irFunction, FakeClassCodegen(irFunction, codegen.classCodegen), CallSiteMarker(codegen.lastLineNumber))
}
private fun getFunctionToInline(call: IrCall, jvmSignature: JvmMethodSignature, callDefault: Boolean): IrFunction {
val callee = call.symbol.owner
private fun getFunctionToInline(jvmSignature: JvmMethodSignature, callDefault: Boolean): IrFunction {
val parent = callee.parentAsClass
if (callDefault) {
/*TODO: get rid of hack*/