JVM IR: Resolve fake overrides when calculating return types (KT-44867)

This commit is contained in:
Steven Schäfer
2021-03-10 12:51:39 +01:00
committed by Alexander Udalov
parent cae95b1ba0
commit d0424465b8
12 changed files with 58 additions and 4 deletions
@@ -497,7 +497,7 @@ class ExpressionCodegen(
// is methods that do not pass through the state machine generating MethodVisitor, since getting
// COROUTINE_SUSPENDED here is still possible; luckily, all those methods are bridges.
if (callable.asmMethod.returnType != Type.VOID_TYPE)
MaterialValue(this, callable.asmMethod.returnType, callee.returnType).discard()
MaterialValue(this, callable.asmMethod.returnType, callable.returnType).discard()
// don't generate redundant UNIT/pop instructions
unitValue
}
@@ -522,7 +522,7 @@ class ExpressionCodegen(
}
}
else ->
MaterialValue(this, callable.asmMethod.returnType, callee.returnType)
MaterialValue(this, callable.asmMethod.returnType, callable.returnType)
}
}
@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.backend.jvm.codegen
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterKind
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature
import org.jetbrains.org.objectweb.asm.Type
@@ -15,7 +16,8 @@ class IrCallableMethod(
val owner: Type,
val invokeOpcode: Int,
val signature: JvmMethodSignature,
val isInterfaceMethod: Boolean
val isInterfaceMethod: Boolean,
val returnType: IrType,
) {
val asmMethod: Method = signature.asmMethod
@@ -418,7 +418,7 @@ class MethodSignatureMapper(private val context: JvmBackendContext) {
?: mapSignatureSkipGeneric(declaration)
}
return IrCallableMethod(owner, invokeOpcode, signature, isInterface)
return IrCallableMethod(owner, invokeOpcode, signature, isInterface, declaration.returnType)
}
// TODO: get rid of this (probably via some special lowering)