JVM IR: Use INVOKESPECIAL instead of INVOKEVIRTUAL for default private
suspend functions. #KT-26592
This commit is contained in:
+6
@@ -9549,6 +9549,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/coroutines/featureIntersection/interfaceMethodWithBodyGeneric.kt");
|
runTest("compiler/testData/codegen/box/coroutines/featureIntersection/interfaceMethodWithBodyGeneric.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("jvmDefault.kt")
|
||||||
|
public void testJvmDefault() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/coroutines/featureIntersection/jvmDefault.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("overrideInInlineClass.kt")
|
@TestMetadata("overrideInInlineClass.kt")
|
||||||
public void testOverrideInInlineClass() throws Exception {
|
public void testOverrideInInlineClass() throws Exception {
|
||||||
|
|||||||
+1
-1
@@ -403,7 +403,7 @@ class MethodSignatureMapper(private val context: JvmBackendContext) {
|
|||||||
callee.dispatchReceiverParameter == null -> Opcodes.INVOKESTATIC
|
callee.dispatchReceiverParameter == null -> Opcodes.INVOKESTATIC
|
||||||
isSuperCall -> Opcodes.INVOKESPECIAL
|
isSuperCall -> Opcodes.INVOKESPECIAL
|
||||||
isInterface && !DescriptorVisibilities.isPrivate(callee.visibility) -> Opcodes.INVOKEINTERFACE
|
isInterface && !DescriptorVisibilities.isPrivate(callee.visibility) -> Opcodes.INVOKEINTERFACE
|
||||||
DescriptorVisibilities.isPrivate(callee.visibility) && !callee.isSuspend -> Opcodes.INVOKESPECIAL
|
DescriptorVisibilities.isPrivate(callee.visibility) -> Opcodes.INVOKESPECIAL
|
||||||
else -> Opcodes.INVOKEVIRTUAL
|
else -> Opcodes.INVOKEVIRTUAL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
// WITH_RUNTIME
|
||||||
|
// !JVM_DEFAULT_MODE: all
|
||||||
|
// TARGET_BACKEND: JVM
|
||||||
|
// JVM_TARGET: 1.8
|
||||||
|
// IGNORE_BACKEND: JVM
|
||||||
|
|
||||||
|
import kotlin.coroutines.*
|
||||||
|
|
||||||
|
interface Foo {
|
||||||
|
private suspend fun test(): String {
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun foo(): String {
|
||||||
|
return test()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun builder(c: suspend () -> Unit) {
|
||||||
|
c.startCoroutine(Continuation(EmptyCoroutineContext) {
|
||||||
|
it.getOrThrow()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
var res = "FAIL"
|
||||||
|
|
||||||
|
builder {
|
||||||
|
val foo: Foo = object : Foo{}
|
||||||
|
res = foo.foo()
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
+6
@@ -9549,6 +9549,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/coroutines/featureIntersection/interfaceMethodWithBodyGeneric.kt");
|
runTest("compiler/testData/codegen/box/coroutines/featureIntersection/interfaceMethodWithBodyGeneric.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("jvmDefault.kt")
|
||||||
|
public void testJvmDefault() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/coroutines/featureIntersection/jvmDefault.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("overrideInInlineClass.kt")
|
@TestMetadata("overrideInInlineClass.kt")
|
||||||
public void testOverrideInInlineClass() throws Exception {
|
public void testOverrideInInlineClass() throws Exception {
|
||||||
|
|||||||
+6
@@ -9549,6 +9549,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/coroutines/featureIntersection/interfaceMethodWithBodyGeneric.kt");
|
runTest("compiler/testData/codegen/box/coroutines/featureIntersection/interfaceMethodWithBodyGeneric.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("jvmDefault.kt")
|
||||||
|
public void testJvmDefault() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/coroutines/featureIntersection/jvmDefault.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("overrideInInlineClass.kt")
|
@TestMetadata("overrideInInlineClass.kt")
|
||||||
public void testOverrideInInlineClass() throws Exception {
|
public void testOverrideInInlineClass() throws Exception {
|
||||||
|
|||||||
+5
@@ -7517,6 +7517,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface.kt");
|
runTest("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jvmDefault.kt")
|
||||||
|
public void ignoreJvmDefault() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/coroutines/featureIntersection/jvmDefault.kt");
|
||||||
|
}
|
||||||
|
|
||||||
private void runTest(String testDataFilePath) throws Exception {
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
|
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user