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
@@ -17776,6 +17776,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/inlineClasses/kt44141.kt");
}
@Test
@TestMetadata("kt44867.kt")
public void testKt44867() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/kt44867.kt");
}
@Test
@TestMetadata("mangledDefaultParameterFunction.kt")
public void testMangledDefaultParameterFunction() throws Exception {
@@ -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)
@@ -0,0 +1,9 @@
// WITH_RUNTIME
// IGNORE_BACKEND: JVM
open class BaseWrapper<T>(val response: T)
class Wrapper(result: Result<String>) : BaseWrapper<Result<String>>(result)
fun box(): String {
return Wrapper(Result.success("OK")).response.getOrThrow()
}
@@ -17776,6 +17776,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/inlineClasses/kt44141.kt");
}
@Test
@TestMetadata("kt44867.kt")
public void testKt44867() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/kt44867.kt");
}
@Test
@TestMetadata("mangledDefaultParameterFunction.kt")
public void testMangledDefaultParameterFunction() throws Exception {
@@ -17776,6 +17776,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/inlineClasses/kt44141.kt");
}
@Test
@TestMetadata("kt44867.kt")
public void testKt44867() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/kt44867.kt");
}
@Test
@TestMetadata("mangledDefaultParameterFunction.kt")
public void testMangledDefaultParameterFunction() throws Exception {
@@ -14133,6 +14133,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/inlineClasses/kt32793.kt");
}
@TestMetadata("kt44867.kt")
public void ignoreKt44867() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/kt44867.kt");
}
@TestMetadata("simpleSecondaryConstructor.kt")
public void ignoreSimpleSecondaryConstructor() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/simpleSecondaryConstructor.kt");
@@ -12934,6 +12934,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
runTest("compiler/testData/codegen/box/inlineClasses/kt44141.kt");
}
@TestMetadata("kt44867.kt")
public void testKt44867() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/kt44867.kt");
}
@TestMetadata("mangledDefaultParameterFunction.kt")
public void testMangledDefaultParameterFunction() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/mangledDefaultParameterFunction.kt");
@@ -12391,6 +12391,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/inlineClasses/kt44141.kt");
}
@TestMetadata("kt44867.kt")
public void testKt44867() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/kt44867.kt");
}
@TestMetadata("mangledDefaultParameterFunction.kt")
public void testMangledDefaultParameterFunction() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/mangledDefaultParameterFunction.kt");
@@ -12456,6 +12456,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/inlineClasses/kt44141.kt");
}
@TestMetadata("kt44867.kt")
public void testKt44867() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/kt44867.kt");
}
@TestMetadata("mangledDefaultParameterFunction.kt")
public void testMangledDefaultParameterFunction() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/mangledDefaultParameterFunction.kt");
@@ -6787,6 +6787,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
runTest("compiler/testData/codegen/box/inlineClasses/kt44141.kt");
}
@TestMetadata("kt44867.kt")
public void testKt44867() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/kt44867.kt");
}
@TestMetadata("mangledDefaultParameterFunction.kt")
public void testMangledDefaultParameterFunction() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/mangledDefaultParameterFunction.kt");