JVM IR: take IrFunction in IrTypeMapper.mapFunctionName/mapReturnType
This commit is contained in:
+7
-4
@@ -5,7 +5,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.backend.jvm.codegen
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.ir.returnType
|
||||
import org.jetbrains.kotlin.backend.common.lower.BOUND_RECEIVER_PARAMETER
|
||||
import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
|
||||
import org.jetbrains.kotlin.backend.jvm.intrinsics.IrIntrinsicMethods
|
||||
@@ -659,7 +658,11 @@ class ExpressionCodegen(
|
||||
}
|
||||
|
||||
override fun visitReturn(expression: IrReturn, data: BlockInfo): PromisedValue {
|
||||
val owner = expression.returnTargetSymbol.owner
|
||||
val returnTarget = expression.returnTargetSymbol.owner
|
||||
val owner =
|
||||
returnTarget as? IrFunction
|
||||
?: (returnTarget as? IrReturnableBlock)?.inlineFunctionSymbol?.owner
|
||||
?: error("Unsupported IrReturnTarget: $returnTarget")
|
||||
//TODO: should be owner != irFunction
|
||||
val isNonLocalReturn =
|
||||
typeMapper.mapFunctionName(owner, OwnerKind.IMPLEMENTATION) != typeMapper.mapFunctionName(irFunction, OwnerKind.IMPLEMENTATION)
|
||||
@@ -675,7 +678,7 @@ class ExpressionCodegen(
|
||||
val target = data.findBlock<ReturnableBlockInfo> { it.returnSymbol == expression.returnTargetSymbol }
|
||||
val returnType = typeMapper.mapReturnType(owner)
|
||||
val afterReturnLabel = Label()
|
||||
expression.value.accept(this, data).coerce(returnType, owner.returnType(context)).materialize()
|
||||
expression.value.accept(this, data).coerce(returnType, owner.returnType).materialize()
|
||||
generateFinallyBlocksIfNeeded(returnType, afterReturnLabel, data, target)
|
||||
expression.markLineNumber(startOffset = true)
|
||||
if (target != null) {
|
||||
@@ -683,7 +686,7 @@ class ExpressionCodegen(
|
||||
mv.fixStackAndJump(target.returnLabel)
|
||||
} else {
|
||||
if (isNonLocalReturn) {
|
||||
generateGlobalReturnFlag(mv, (owner as IrFunction).name.asString())
|
||||
generateGlobalReturnFlag(mv, owner.name.asString())
|
||||
}
|
||||
mv.areturn(returnType)
|
||||
}
|
||||
|
||||
+4
-4
@@ -51,14 +51,14 @@ class IrTypeMapper(private val context: JvmBackendContext) {
|
||||
fun mapFieldSignature(irField: IrField) =
|
||||
kotlinTypeMapper.mapFieldSignature(irField.type.toKotlinType(), irField.descriptor)
|
||||
|
||||
fun mapFunctionName(irReturnTarget: IrReturnTarget, ownerKind: OwnerKind): String =
|
||||
kotlinTypeMapper.mapFunctionName(irReturnTarget.descriptor, ownerKind)
|
||||
fun mapFunctionName(irFunction: IrFunction, ownerKind: OwnerKind): String =
|
||||
kotlinTypeMapper.mapFunctionName(irFunction.descriptor, ownerKind)
|
||||
|
||||
fun mapImplementationOwner(irDeclaration: IrDeclaration): Type =
|
||||
kotlinTypeMapper.mapImplementationOwner(irDeclaration.descriptor)
|
||||
|
||||
fun mapReturnType(irReturnTarget: IrReturnTarget): Type =
|
||||
kotlinTypeMapper.mapReturnType(irReturnTarget.descriptor)
|
||||
fun mapReturnType(irFunction: IrFunction): Type =
|
||||
kotlinTypeMapper.mapReturnType(irFunction.descriptor)
|
||||
|
||||
fun mapSignatureSkipGeneric(f: IrFunction, kind: OwnerKind = OwnerKind.IMPLEMENTATION): JvmMethodSignature =
|
||||
kotlinTypeMapper.mapSignatureSkipGeneric(f.descriptor, kind)
|
||||
|
||||
Reference in New Issue
Block a user