diff --git a/compiler/testData/codegen/bytecodeText/defaultArguments/localVariablesInInlinedDefaultStubs.kt b/compiler/testData/codegen/bytecodeText/defaultArguments/localVariablesInInlinedDefaultStubs.kt new file mode 100644 index 00000000000..38089c92025 --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/defaultArguments/localVariablesInInlinedDefaultStubs.kt @@ -0,0 +1,16 @@ +inline fun test(p: String = "OK"): String { + var x = 1 + return p +} + +fun box() : String { + return test() +} + +// No $iv suffix on LVT entries in test and test$default +// 2 LOCALVARIABLE p Ljava/lang/String; +// 2 LOCALVARIABLE x I + +// The $iv suffix should be present in box +// 1 LOCALVARIABLE p\$iv Ljava/lang/String; +// 1 LOCALVARIABLE x\$iv I diff --git a/compiler/testData/codegen/bytecodeText/defaultArguments/noAnonymousObjectRegenerationInDefaultStub.kt b/compiler/testData/codegen/bytecodeText/defaultArguments/noAnonymousObjectRegenerationInDefaultStub.kt new file mode 100644 index 00000000000..7aa0a0d4a7a --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/defaultArguments/noAnonymousObjectRegenerationInDefaultStub.kt @@ -0,0 +1,19 @@ +// FILE: test.kt + +inline fun test(x: T, p: String = "OK"): T { + return object { fun f() = p as T }.f() +} + +fun box() : String { + return test("Fail") +} + +// The test and test$default methods use the *same* anonymous object +// 2 INVOKESPECIAL TestKt\$test\$1. \(Ljava/lang/String;\)V + +// The box method has to regenerate it to instantiate the reified type parameter, +// but the name of the regenerated object differs between the JVM and JVM IR backends. +// JVM_TEMPLATES: +// 1 INVOKESPECIAL TestKt\$box\$\$inlined\$test\$1. \(Ljava/lang/String;\)V +// JVM_IR_TEMPLATES: +// 1 INVOKESPECIAL TestKt\$box\$\$inlined\$test\$default\$1. \(Ljava/lang/String;\)V diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java index fffa0fd1e94..3e1313fd452 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java @@ -1829,6 +1829,11 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/defaultArguments/kt11962.kt"); } + @TestMetadata("localVariablesInInlinedDefaultStubs.kt") + public void testLocalVariablesInInlinedDefaultStubs() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/defaultArguments/localVariablesInInlinedDefaultStubs.kt"); + } + @TestMetadata("maskAndArgumentElimination.kt") public void testMaskAndArgumentElimination() throws Exception { runTest("compiler/testData/codegen/bytecodeText/defaultArguments/maskAndArgumentElimination.kt"); @@ -1849,6 +1854,11 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/defaultArguments/noAccessorForDefault.kt"); } + @TestMetadata("noAnonymousObjectRegenerationInDefaultStub.kt") + public void testNoAnonymousObjectRegenerationInDefaultStub() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/defaultArguments/noAnonymousObjectRegenerationInDefaultStub.kt"); + } + @TestMetadata("noEmptyArray.kt") public void testNoEmptyArray() throws Exception { runTest("compiler/testData/codegen/bytecodeText/defaultArguments/noEmptyArray.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeTextTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeTextTestGenerated.java index f70acde9c75..daefb1394b4 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeTextTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeTextTestGenerated.java @@ -1784,6 +1784,11 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/defaultArguments/kt11962.kt"); } + @TestMetadata("localVariablesInInlinedDefaultStubs.kt") + public void testLocalVariablesInInlinedDefaultStubs() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/defaultArguments/localVariablesInInlinedDefaultStubs.kt"); + } + @TestMetadata("maskAndArgumentElimination.kt") public void testMaskAndArgumentElimination() throws Exception { runTest("compiler/testData/codegen/bytecodeText/defaultArguments/maskAndArgumentElimination.kt"); @@ -1804,6 +1809,11 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/defaultArguments/noAccessorForDefault.kt"); } + @TestMetadata("noAnonymousObjectRegenerationInDefaultStub.kt") + public void testNoAnonymousObjectRegenerationInDefaultStub() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/defaultArguments/noAnonymousObjectRegenerationInDefaultStub.kt"); + } + @TestMetadata("noEmptyArray.kt") public void testNoEmptyArray() throws Exception { runTest("compiler/testData/codegen/bytecodeText/defaultArguments/noEmptyArray.kt");