JVM_IR: repair super calls to methods of Any

This commit is contained in:
Georgy Bronnikov
2020-04-14 21:10:23 +03:00
parent 4d1b5b84f8
commit 611c4fe052
4 changed files with 23 additions and 1 deletions
@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.backend.jvm.codegen
import org.jetbrains.kotlin.backend.common.ir.isMethodOfAny
import org.jetbrains.kotlin.backend.common.ir.isTopLevel
import org.jetbrains.kotlin.backend.common.lower.allOverridden
import org.jetbrains.kotlin.backend.common.lower.parentsWithSelf
@@ -358,7 +359,9 @@ class MethodSignatureMapper(private val context: JvmBackendContext) {
continue
}
if (isSuperCall && !current.parentAsClass.isInterface &&
current.resolveFakeOverride()?.isCompiledToJvmDefault(context.state.jvmDefaultMode) != true
current.resolveFakeOverride()?.run {
isMethodOfAny() || !isCompiledToJvmDefault(context.state.jvmDefaultMode)
} == true
) {
return current
}
@@ -0,0 +1,9 @@
interface A
abstract class Base: A
class Derived : Base() {
override fun toString() = super.toString()
}
// 1 INVOKESPECIAL Base.toString
@@ -409,6 +409,11 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
runTest("compiler/testData/codegen/bytecodeText/superFlagInMultiFileFacade.kt");
}
@TestMetadata("superToString.kt")
public void testSuperToString() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/superToString.kt");
}
@TestMetadata("suspendCoroutineUninterceptedOrReturn.kt")
public void testSuspendCoroutineUninterceptedOrReturn() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/suspendCoroutineUninterceptedOrReturn.kt");
@@ -409,6 +409,11 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest {
runTest("compiler/testData/codegen/bytecodeText/superFlagInMultiFileFacade.kt");
}
@TestMetadata("superToString.kt")
public void testSuperToString() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/superToString.kt");
}
@TestMetadata("suspendCoroutineUninterceptedOrReturn.kt")
public void testSuspendCoroutineUninterceptedOrReturn() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/suspendCoroutineUninterceptedOrReturn.kt");