JVM_IR KT-45408 rewrite static calls recursively

This commit is contained in:
Dmitry Petrov
2021-03-19 14:02:32 +03:00
committed by TeamCityServer
parent e5f218859b
commit f6baabd98e
6 changed files with 36 additions and 0 deletions
@@ -23422,6 +23422,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/jvmStatic/kt35716.kt");
}
@Test
@TestMetadata("kt45408.kt")
public void testKt45408() throws Exception {
runTest("compiler/testData/codegen/box/jvmStatic/kt45408.kt");
}
@Test
@TestMetadata("kt9897_static.kt")
public void testKt9897_static() throws Exception {
@@ -150,6 +150,7 @@ private class MakeCallsStatic(val context: JvmBackendContext) : IrElementTransfo
override fun visitMemberAccess(expression: IrMemberAccessExpression<*>): IrExpression {
val callee = expression.symbol.owner
if (callee is IrDeclaration && callee.isJvmStaticInObject() && expression.dispatchReceiver != null) {
expression.transformChildrenVoid()
return context.createIrBuilder(expression.symbol, expression.startOffset, expression.endOffset).irBlock(expression) {
// OldReceiver has to be evaluated for its side effects.
val oldReceiver = super.visitExpression(expression.dispatchReceiver!!)
+12
View File
@@ -0,0 +1,12 @@
// TARGET_BACKEND: JVM
// WITH_RUNTIME
fun box() = X.tag().d()
object X {
@JvmStatic
fun d(): String = "OK"
@JvmStatic
fun tag(): X = this
}
@@ -23422,6 +23422,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/jvmStatic/kt35716.kt");
}
@Test
@TestMetadata("kt45408.kt")
public void testKt45408() throws Exception {
runTest("compiler/testData/codegen/box/jvmStatic/kt45408.kt");
}
@Test
@TestMetadata("kt9897_static.kt")
public void testKt9897_static() throws Exception {
@@ -23422,6 +23422,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/jvmStatic/kt35716.kt");
}
@Test
@TestMetadata("kt45408.kt")
public void testKt45408() throws Exception {
runTest("compiler/testData/codegen/box/jvmStatic/kt45408.kt");
}
@Test
@TestMetadata("kt9897_static.kt")
public void testKt9897_static() throws Exception {
@@ -19779,6 +19779,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/jvmStatic/kt35716.kt");
}
@TestMetadata("kt45408.kt")
public void testKt45408() throws Exception {
runTest("compiler/testData/codegen/box/jvmStatic/kt45408.kt");
}
@TestMetadata("kt9897_static.kt")
public void testKt9897_static() throws Exception {
runTest("compiler/testData/codegen/box/jvmStatic/kt9897_static.kt");