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:
+1
-1
@@ -989,7 +989,7 @@ class ExpressionCodegen(
|
|||||||
|
|
||||||
val original = (callee as? IrSimpleFunction)?.resolveFakeOverride() ?: irFunction
|
val original = (callee as? IrSimpleFunction)?.resolveFakeOverride() ?: irFunction
|
||||||
val methodOwner = callee.parent.safeAs<IrClass>()?.let(typeMapper::mapClass) ?: MethodSignatureMapper.FAKE_OWNER_TYPE
|
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> {
|
val reifiedTypeInliner = ReifiedTypeInliner(mappings, object : ReifiedTypeInliner.IntrinsicsSupport<IrType> {
|
||||||
override fun putClassInstance(v: InstructionAdapter, type: IrType) {
|
override fun putClassInstance(v: InstructionAdapter, type: IrType) {
|
||||||
|
|||||||
+4
-5
@@ -21,7 +21,6 @@ import org.jetbrains.kotlin.incremental.components.LookupLocation
|
|||||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrClass
|
import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
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.expressions.IrMemberAccessExpression
|
||||||
import org.jetbrains.kotlin.ir.util.parentAsClass
|
import org.jetbrains.kotlin.ir.util.parentAsClass
|
||||||
import org.jetbrains.kotlin.ir.util.render
|
import org.jetbrains.kotlin.ir.util.render
|
||||||
@@ -37,6 +36,7 @@ import org.jetbrains.org.objectweb.asm.tree.MethodNode
|
|||||||
class IrSourceCompilerForInline(
|
class IrSourceCompilerForInline(
|
||||||
override val state: GenerationState,
|
override val state: GenerationState,
|
||||||
override val callElement: IrMemberAccessExpression,
|
override val callElement: IrMemberAccessExpression,
|
||||||
|
private val callee: IrFunction,
|
||||||
private val codegen: ExpressionCodegen,
|
private val codegen: ExpressionCodegen,
|
||||||
private val data: BlockInfo
|
private val data: BlockInfo
|
||||||
) : SourceCompilerForInline {
|
) : SourceCompilerForInline {
|
||||||
@@ -94,15 +94,14 @@ class IrSourceCompilerForInline(
|
|||||||
callDefault: Boolean,
|
callDefault: Boolean,
|
||||||
asmMethod: Method
|
asmMethod: Method
|
||||||
): SMAPAndMethodNode {
|
): 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}" }
|
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))
|
return makeInlineNode(irFunction, FakeClassCodegen(irFunction, codegen.classCodegen), CallSiteMarker(codegen.lastLineNumber))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getFunctionToInline(call: IrCall, jvmSignature: JvmMethodSignature, callDefault: Boolean): IrFunction {
|
private fun getFunctionToInline(jvmSignature: JvmMethodSignature, callDefault: Boolean): IrFunction {
|
||||||
val callee = call.symbol.owner
|
|
||||||
val parent = callee.parentAsClass
|
val parent = callee.parentAsClass
|
||||||
if (callDefault) {
|
if (callDefault) {
|
||||||
/*TODO: get rid of hack*/
|
/*TODO: get rid of hack*/
|
||||||
|
|||||||
Reference in New Issue
Block a user