Cast dispatch receiver to actual declaration owner though inline
Otherwise corrupted frame information is generated in bytecode #KT-29242 Fixed
This commit is contained in:
@@ -2655,7 +2655,8 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
return new InlineCodegenForDefaultBody(functionDescriptor, this, state, methodOwner, signature, sourceCompiler);
|
return new InlineCodegenForDefaultBody(functionDescriptor, this, state, methodOwner, signature, sourceCompiler);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return new PsiInlineCodegen(this, state, functionDescriptor, methodOwner, signature, typeParameterMappings, sourceCompiler);
|
return new PsiInlineCodegen(this, state, functionDescriptor, methodOwner, signature, typeParameterMappings, sourceCompiler,
|
||||||
|
typeMapper.mapOwner(descriptor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
|
|||||||
protected val codegen: T,
|
protected val codegen: T,
|
||||||
protected val state: GenerationState,
|
protected val state: GenerationState,
|
||||||
protected val functionDescriptor: FunctionDescriptor,
|
protected val functionDescriptor: FunctionDescriptor,
|
||||||
private val methodOwner: Type,
|
protected val methodOwner: Type,
|
||||||
protected val jvmSignature: JvmMethodSignature,
|
protected val jvmSignature: JvmMethodSignature,
|
||||||
private val typeParameterMappings: TypeParameterMappings<*>,
|
private val typeParameterMappings: TypeParameterMappings<*>,
|
||||||
protected val sourceCompiler: SourceCompilerForInline,
|
protected val sourceCompiler: SourceCompilerForInline,
|
||||||
@@ -427,7 +427,7 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
|
|||||||
val type = info.type
|
val type = info.type
|
||||||
val local = StackValue.local(index[i], type)
|
val local = StackValue.local(index[i], type)
|
||||||
if (!skipStore) {
|
if (!skipStore) {
|
||||||
local.store(StackValue.onStack(type), codegen.v)
|
local.store(StackValue.onStack(info.typeOnStack), codegen.v)
|
||||||
}
|
}
|
||||||
if (info is CapturedParamInfo) {
|
if (info is CapturedParamInfo) {
|
||||||
info.remapValue = local
|
info.remapValue = local
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ open class ParameterInfo(
|
|||||||
val isSkipped: Boolean, //for skipped parameter: e.g. inlined lambda
|
val isSkipped: Boolean, //for skipped parameter: e.g. inlined lambda
|
||||||
val index: Int,
|
val index: Int,
|
||||||
var remapValue: StackValue?, //in case when parameter could be extracted from outer context (e.g. from local var)
|
var remapValue: StackValue?, //in case when parameter could be extracted from outer context (e.g. from local var)
|
||||||
val declarationIndex: Int
|
val declarationIndex: Int,
|
||||||
|
val typeOnStack: Type = type
|
||||||
) {
|
) {
|
||||||
|
|
||||||
var isCaptured: Boolean = false
|
var isCaptured: Boolean = false
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ class ParametersBuilder private constructor() {
|
|||||||
return addParameter(ParameterInfo(type, skipped, nextParameterOffset, -1, nextValueParameterIndex))
|
return addParameter(ParameterInfo(type, skipped, nextParameterOffset, -1, nextValueParameterIndex))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addNextParameter(type: Type, skipped: Boolean): ParameterInfo {
|
fun addNextParameter(type: Type, skipped: Boolean, typeOnStack: Type = type): ParameterInfo {
|
||||||
return addParameter(ParameterInfo(type, skipped, nextParameterOffset, null, nextValueParameterIndex))
|
return addParameter(ParameterInfo(type, skipped, nextParameterOffset, null, nextValueParameterIndex, typeOnStack))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addNextValueParameter(type: Type, skipped: Boolean, remapValue: StackValue?, parameterIndex: Int): ParameterInfo {
|
fun addNextValueParameter(type: Type, skipped: Boolean, remapValue: StackValue?, parameterIndex: Int): ParameterInfo {
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCallWithAssert
|
|||||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||||
import org.jetbrains.kotlin.resolve.inline.InlineUtil
|
import org.jetbrains.kotlin.resolve.inline.InlineUtil
|
||||||
import org.jetbrains.kotlin.resolve.inline.InlineUtil.isInlinableParameterExpression
|
import org.jetbrains.kotlin.resolve.inline.InlineUtil.isInlinableParameterExpression
|
||||||
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
|
|
||||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterKind
|
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterKind
|
||||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature
|
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||||
@@ -36,7 +35,8 @@ class PsiInlineCodegen(
|
|||||||
methodOwner: Type,
|
methodOwner: Type,
|
||||||
signature: JvmMethodSignature,
|
signature: JvmMethodSignature,
|
||||||
typeParameterMappings: TypeParameterMappings<KotlinType>,
|
typeParameterMappings: TypeParameterMappings<KotlinType>,
|
||||||
sourceCompiler: SourceCompilerForInline
|
sourceCompiler: SourceCompilerForInline,
|
||||||
|
private val actualDispatchReceiver: Type = methodOwner
|
||||||
) : InlineCodegen<ExpressionCodegen>(
|
) : InlineCodegen<ExpressionCodegen>(
|
||||||
codegen, state, function, methodOwner, signature, typeParameterMappings, sourceCompiler,
|
codegen, state, function, methodOwner, signature, typeParameterMappings, sourceCompiler,
|
||||||
ReifiedTypeInliner(typeParameterMappings, object : ReifiedTypeInliner.IntrinsicsSupport<KotlinType> {
|
ReifiedTypeInliner(typeParameterMappings, object : ReifiedTypeInliner.IntrinsicsSupport<KotlinType> {
|
||||||
@@ -73,7 +73,7 @@ class PsiInlineCodegen(
|
|||||||
|
|
||||||
override fun processAndPutHiddenParameters(justProcess: Boolean) {
|
override fun processAndPutHiddenParameters(justProcess: Boolean) {
|
||||||
if (getMethodAsmFlags(functionDescriptor, sourceCompiler.contextKind, state) and Opcodes.ACC_STATIC == 0) {
|
if (getMethodAsmFlags(functionDescriptor, sourceCompiler.contextKind, state) and Opcodes.ACC_STATIC == 0) {
|
||||||
invocationParamBuilder.addNextParameter(AsmTypes.OBJECT_TYPE, false)
|
invocationParamBuilder.addNextParameter(methodOwner, false, actualDispatchReceiver)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (param in jvmSignature.valueParameters) {
|
for (param in jvmSignature.valueParameters) {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
// TARGET_BACKEND: JVM
|
// TARGET_BACKEND: JVM
|
||||||
// IGNORE_BACKEND: JVM
|
|
||||||
// JVM_TARGET: 1.8
|
// JVM_TARGET: 1.8
|
||||||
// See also kt33054.kt
|
// See also kt33054.kt
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user