From edd3b457d4fdeb64d19e6be3cd571462b65e5388 Mon Sep 17 00:00:00 2001 From: Kristoffer Andersen Date: Wed, 4 Nov 2020 13:12:37 +0100 Subject: [PATCH] [JVM+IR] Migrate/improve receiver mangling test suite --- .../asmLike/receiverMangling/innerClass.kt | 3 -- .../asmLike/receiverMangling/innerClass.txt | 9 ---- .../asmLike/receiverMangling/simple.kt | 1 - .../asmLike/receiverMangling/simple.txt | 3 -- .../receiverMangling/capturedThisField.kt | 21 ++++++++ .../labeledThisParameterLabel.kt | 19 +++++++ .../lambdaWithExtensionReceiver.kt | 0 .../receiverParameter.kt | 0 .../simpleCapturedReceiver.kt | 19 +++++++ .../simpleCapturedReceiverWithLabel.kt | 19 +++++++ .../simpleCapturedReceiverWithParenthesis.kt | 19 +++++++ ...smLikeInstructionListingTestGenerated.java | 10 ---- .../IrLocalVariableTestGenerated.java | 54 ++++++++++++++----- .../LocalVariableTestGenerated.java | 54 ++++++++++++++----- ...smLikeInstructionListingTestGenerated.java | 10 ---- 15 files changed, 181 insertions(+), 60 deletions(-) delete mode 100644 compiler/testData/codegen/asmLike/receiverMangling/innerClass.kt delete mode 100644 compiler/testData/codegen/asmLike/receiverMangling/innerClass.txt delete mode 100644 compiler/testData/codegen/asmLike/receiverMangling/simple.kt delete mode 100644 compiler/testData/codegen/asmLike/receiverMangling/simple.txt create mode 100644 compiler/testData/debug/localVariables/receiverMangling/capturedThisField.kt create mode 100644 compiler/testData/debug/localVariables/receiverMangling/labeledThisParameterLabel.kt rename compiler/testData/debug/localVariables/{ => receiverMangling}/lambdaWithExtensionReceiver.kt (100%) rename compiler/testData/debug/localVariables/{ => receiverMangling}/receiverParameter.kt (100%) create mode 100644 compiler/testData/debug/localVariables/receiverMangling/simpleCapturedReceiver.kt create mode 100644 compiler/testData/debug/localVariables/receiverMangling/simpleCapturedReceiverWithLabel.kt create mode 100644 compiler/testData/debug/localVariables/receiverMangling/simpleCapturedReceiverWithParenthesis.kt diff --git a/compiler/testData/codegen/asmLike/receiverMangling/innerClass.kt b/compiler/testData/codegen/asmLike/receiverMangling/innerClass.kt deleted file mode 100644 index 690ce27852a..00000000000 --- a/compiler/testData/codegen/asmLike/receiverMangling/innerClass.kt +++ /dev/null @@ -1,3 +0,0 @@ -class Foo { - inner class Bar -} \ No newline at end of file diff --git a/compiler/testData/codegen/asmLike/receiverMangling/innerClass.txt b/compiler/testData/codegen/asmLike/receiverMangling/innerClass.txt deleted file mode 100644 index 9d1a34b62b5..00000000000 --- a/compiler/testData/codegen/asmLike/receiverMangling/innerClass.txt +++ /dev/null @@ -1,9 +0,0 @@ -public final class Foo$Bar : java/lang/Object { - final Foo this$0 - - public void (Foo this$0) -} - -public final class Foo : java/lang/Object { - public void () -} diff --git a/compiler/testData/codegen/asmLike/receiverMangling/simple.kt b/compiler/testData/codegen/asmLike/receiverMangling/simple.kt deleted file mode 100644 index 02956a31e98..00000000000 --- a/compiler/testData/codegen/asmLike/receiverMangling/simple.kt +++ /dev/null @@ -1 +0,0 @@ -fun String.foo(a: Int) {} \ No newline at end of file diff --git a/compiler/testData/codegen/asmLike/receiverMangling/simple.txt b/compiler/testData/codegen/asmLike/receiverMangling/simple.txt deleted file mode 100644 index d528fedc150..00000000000 --- a/compiler/testData/codegen/asmLike/receiverMangling/simple.txt +++ /dev/null @@ -1,3 +0,0 @@ -public final class SimpleKt : java/lang/Object { - public final static void foo(java.lang.String $this$foo, int a) -} diff --git a/compiler/testData/debug/localVariables/receiverMangling/capturedThisField.kt b/compiler/testData/debug/localVariables/receiverMangling/capturedThisField.kt new file mode 100644 index 00000000000..4dd7c6e5df2 --- /dev/null +++ b/compiler/testData/debug/localVariables/receiverMangling/capturedThisField.kt @@ -0,0 +1,21 @@ + + +// FILE: test.kt +class Foo { + inner class Bar { + } +} + +fun box() { + val x = Foo() + x.Bar() +} + +// LOCAL VARIABLES +// test.kt:10 box: +// test.kt:4 : +// test.kt:10 box: +// test.kt:11 box: x:Foo=Foo +// test.kt:5 : +// test.kt:11 box: x:Foo=Foo +// test.kt:12 box: x:Foo=Foo \ No newline at end of file diff --git a/compiler/testData/debug/localVariables/receiverMangling/labeledThisParameterLabel.kt b/compiler/testData/debug/localVariables/receiverMangling/labeledThisParameterLabel.kt new file mode 100644 index 00000000000..00023618456 --- /dev/null +++ b/compiler/testData/debug/localVariables/receiverMangling/labeledThisParameterLabel.kt @@ -0,0 +1,19 @@ + + +// FILE: test.kt +fun blockFun(blockArg: String.() -> Unit) = + "OK".blockArg() + +fun box() { + blockFun { + println(this) + } +} + +// LOCAL VARIABLES +// test.kt:8 box: +// test.kt:5 blockFun: blockArg:kotlin.jvm.functions.Function1=TestKt$box$1 +// test.kt:9 invoke: $this$blockFun:java.lang.String="OK":java.lang.String +// test.kt:10 invoke: $this$blockFun:java.lang.String="OK":java.lang.String +// test.kt:5 blockFun: blockArg:kotlin.jvm.functions.Function1=TestKt$box$1 +// test.kt:11 box: \ No newline at end of file diff --git a/compiler/testData/debug/localVariables/lambdaWithExtensionReceiver.kt b/compiler/testData/debug/localVariables/receiverMangling/lambdaWithExtensionReceiver.kt similarity index 100% rename from compiler/testData/debug/localVariables/lambdaWithExtensionReceiver.kt rename to compiler/testData/debug/localVariables/receiverMangling/lambdaWithExtensionReceiver.kt diff --git a/compiler/testData/debug/localVariables/receiverParameter.kt b/compiler/testData/debug/localVariables/receiverMangling/receiverParameter.kt similarity index 100% rename from compiler/testData/debug/localVariables/receiverParameter.kt rename to compiler/testData/debug/localVariables/receiverMangling/receiverParameter.kt diff --git a/compiler/testData/debug/localVariables/receiverMangling/simpleCapturedReceiver.kt b/compiler/testData/debug/localVariables/receiverMangling/simpleCapturedReceiver.kt new file mode 100644 index 00000000000..00023618456 --- /dev/null +++ b/compiler/testData/debug/localVariables/receiverMangling/simpleCapturedReceiver.kt @@ -0,0 +1,19 @@ + + +// FILE: test.kt +fun blockFun(blockArg: String.() -> Unit) = + "OK".blockArg() + +fun box() { + blockFun { + println(this) + } +} + +// LOCAL VARIABLES +// test.kt:8 box: +// test.kt:5 blockFun: blockArg:kotlin.jvm.functions.Function1=TestKt$box$1 +// test.kt:9 invoke: $this$blockFun:java.lang.String="OK":java.lang.String +// test.kt:10 invoke: $this$blockFun:java.lang.String="OK":java.lang.String +// test.kt:5 blockFun: blockArg:kotlin.jvm.functions.Function1=TestKt$box$1 +// test.kt:11 box: \ No newline at end of file diff --git a/compiler/testData/debug/localVariables/receiverMangling/simpleCapturedReceiverWithLabel.kt b/compiler/testData/debug/localVariables/receiverMangling/simpleCapturedReceiverWithLabel.kt new file mode 100644 index 00000000000..30f489b6375 --- /dev/null +++ b/compiler/testData/debug/localVariables/receiverMangling/simpleCapturedReceiverWithLabel.kt @@ -0,0 +1,19 @@ + + +// FILE: test.kt +fun blockFun(blockArg: String.() -> Unit) = + "OK".blockArg() + +fun box() { + blockFun label@{ + println(this) + } +} + +// LOCAL VARIABLES +// test.kt:8 box: +// test.kt:5 blockFun: blockArg:kotlin.jvm.functions.Function1=TestKt$box$1 +// test.kt:9 invoke: $this$label:java.lang.String="OK":java.lang.String +// test.kt:10 invoke: $this$label:java.lang.String="OK":java.lang.String +// test.kt:5 blockFun: blockArg:kotlin.jvm.functions.Function1=TestKt$box$1 +// test.kt:11 box: \ No newline at end of file diff --git a/compiler/testData/debug/localVariables/receiverMangling/simpleCapturedReceiverWithParenthesis.kt b/compiler/testData/debug/localVariables/receiverMangling/simpleCapturedReceiverWithParenthesis.kt new file mode 100644 index 00000000000..b955fc00b56 --- /dev/null +++ b/compiler/testData/debug/localVariables/receiverMangling/simpleCapturedReceiverWithParenthesis.kt @@ -0,0 +1,19 @@ + + +// FILE: test.kt +fun blockFun(blockArg: String.() -> Unit) = + "OK".blockArg() + +fun box() { + blockFun ({ + println(this) + }) +} + +// LOCAL VARIABLES +// test.kt:8 box: +// test.kt:5 blockFun: blockArg:kotlin.jvm.functions.Function1=TestKt$box$1 +// test.kt:9 invoke: $this$blockFun:java.lang.String="OK":java.lang.String +// test.kt:10 invoke: $this$blockFun:java.lang.String="OK":java.lang.String +// test.kt:5 blockFun: blockArg:kotlin.jvm.functions.Function1=TestKt$box$1 +// test.kt:11 box: \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/AsmLikeInstructionListingTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/AsmLikeInstructionListingTestGenerated.java index 3745900f1b1..e4b4f5340f9 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/AsmLikeInstructionListingTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/AsmLikeInstructionListingTestGenerated.java @@ -81,11 +81,6 @@ public class AsmLikeInstructionListingTestGenerated extends AbstractAsmLikeInstr runTest("compiler/testData/codegen/asmLike/receiverMangling/inlineReceivers.kt"); } - @TestMetadata("innerClass.kt") - public void testInnerClass() throws Exception { - runTest("compiler/testData/codegen/asmLike/receiverMangling/innerClass.kt"); - } - @TestMetadata("localFunctions.kt") public void testLocalFunctions() throws Exception { runTest("compiler/testData/codegen/asmLike/receiverMangling/localFunctions.kt"); @@ -105,11 +100,6 @@ public class AsmLikeInstructionListingTestGenerated extends AbstractAsmLikeInstr public void testNonInlineReceivers_before() throws Exception { runTest("compiler/testData/codegen/asmLike/receiverMangling/nonInlineReceivers_before.kt"); } - - @TestMetadata("simple.kt") - public void testSimple() throws Exception { - runTest("compiler/testData/codegen/asmLike/receiverMangling/simple.kt"); - } } @TestMetadata("compiler/testData/codegen/asmLike/typeAnnotations") diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/debugInformation/IrLocalVariableTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/debugInformation/IrLocalVariableTestGenerated.java index 7f4f59f31ec..06f802eb132 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/debugInformation/IrLocalVariableTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/debugInformation/IrLocalVariableTestGenerated.java @@ -67,24 +67,12 @@ public class IrLocalVariableTestGenerated extends AbstractIrLocalVariableTest { runTest("compiler/testData/debug/localVariables/jvmOverloads.kt"); } - @Test - @TestMetadata("lambdaWithExtensionReceiver.kt") - public void testLambdaWithExtensionReceiver() throws Exception { - runTest("compiler/testData/debug/localVariables/lambdaWithExtensionReceiver.kt"); - } - @Test @TestMetadata("localFun.kt") public void testLocalFun() throws Exception { runTest("compiler/testData/debug/localVariables/localFun.kt"); } - @Test - @TestMetadata("receiverParameter.kt") - public void testReceiverParameter() throws Exception { - runTest("compiler/testData/debug/localVariables/receiverParameter.kt"); - } - @Test @TestMetadata("underscoreNames.kt") public void testUnderscoreNames() throws Exception { @@ -104,11 +92,53 @@ public class IrLocalVariableTestGenerated extends AbstractIrLocalVariableTest { KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/debug/localVariables/receiverMangling"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("capturedThisField.kt") + public void testCapturedThisField() throws Exception { + runTest("compiler/testData/debug/localVariables/receiverMangling/capturedThisField.kt"); + } + + @Test + @TestMetadata("labeledThisParameterLabel.kt") + public void testLabeledThisParameterLabel() throws Exception { + runTest("compiler/testData/debug/localVariables/receiverMangling/labeledThisParameterLabel.kt"); + } + + @Test + @TestMetadata("lambdaWithExtensionReceiver.kt") + public void testLambdaWithExtensionReceiver() throws Exception { + runTest("compiler/testData/debug/localVariables/receiverMangling/lambdaWithExtensionReceiver.kt"); + } + + @Test + @TestMetadata("receiverParameter.kt") + public void testReceiverParameter() throws Exception { + runTest("compiler/testData/debug/localVariables/receiverMangling/receiverParameter.kt"); + } + @Test @TestMetadata("simple.kt") public void testSimple() throws Exception { runTest("compiler/testData/debug/localVariables/receiverMangling/simple.kt"); } + + @Test + @TestMetadata("simpleCapturedReceiver.kt") + public void testSimpleCapturedReceiver() throws Exception { + runTest("compiler/testData/debug/localVariables/receiverMangling/simpleCapturedReceiver.kt"); + } + + @Test + @TestMetadata("simpleCapturedReceiverWithLabel.kt") + public void testSimpleCapturedReceiverWithLabel() throws Exception { + runTest("compiler/testData/debug/localVariables/receiverMangling/simpleCapturedReceiverWithLabel.kt"); + } + + @Test + @TestMetadata("simpleCapturedReceiverWithParenthesis.kt") + public void testSimpleCapturedReceiverWithParenthesis() throws Exception { + runTest("compiler/testData/debug/localVariables/receiverMangling/simpleCapturedReceiverWithParenthesis.kt"); + } } @TestMetadata("compiler/testData/debug/localVariables/suspend") diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/debugInformation/LocalVariableTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/debugInformation/LocalVariableTestGenerated.java index b7349719a3c..abcc2223d1a 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/debugInformation/LocalVariableTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/debugInformation/LocalVariableTestGenerated.java @@ -67,24 +67,12 @@ public class LocalVariableTestGenerated extends AbstractLocalVariableTest { runTest("compiler/testData/debug/localVariables/jvmOverloads.kt"); } - @Test - @TestMetadata("lambdaWithExtensionReceiver.kt") - public void testLambdaWithExtensionReceiver() throws Exception { - runTest("compiler/testData/debug/localVariables/lambdaWithExtensionReceiver.kt"); - } - @Test @TestMetadata("localFun.kt") public void testLocalFun() throws Exception { runTest("compiler/testData/debug/localVariables/localFun.kt"); } - @Test - @TestMetadata("receiverParameter.kt") - public void testReceiverParameter() throws Exception { - runTest("compiler/testData/debug/localVariables/receiverParameter.kt"); - } - @Test @TestMetadata("underscoreNames.kt") public void testUnderscoreNames() throws Exception { @@ -104,11 +92,53 @@ public class LocalVariableTestGenerated extends AbstractLocalVariableTest { KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/debug/localVariables/receiverMangling"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } + @Test + @TestMetadata("capturedThisField.kt") + public void testCapturedThisField() throws Exception { + runTest("compiler/testData/debug/localVariables/receiverMangling/capturedThisField.kt"); + } + + @Test + @TestMetadata("labeledThisParameterLabel.kt") + public void testLabeledThisParameterLabel() throws Exception { + runTest("compiler/testData/debug/localVariables/receiverMangling/labeledThisParameterLabel.kt"); + } + + @Test + @TestMetadata("lambdaWithExtensionReceiver.kt") + public void testLambdaWithExtensionReceiver() throws Exception { + runTest("compiler/testData/debug/localVariables/receiverMangling/lambdaWithExtensionReceiver.kt"); + } + + @Test + @TestMetadata("receiverParameter.kt") + public void testReceiverParameter() throws Exception { + runTest("compiler/testData/debug/localVariables/receiverMangling/receiverParameter.kt"); + } + @Test @TestMetadata("simple.kt") public void testSimple() throws Exception { runTest("compiler/testData/debug/localVariables/receiverMangling/simple.kt"); } + + @Test + @TestMetadata("simpleCapturedReceiver.kt") + public void testSimpleCapturedReceiver() throws Exception { + runTest("compiler/testData/debug/localVariables/receiverMangling/simpleCapturedReceiver.kt"); + } + + @Test + @TestMetadata("simpleCapturedReceiverWithLabel.kt") + public void testSimpleCapturedReceiverWithLabel() throws Exception { + runTest("compiler/testData/debug/localVariables/receiverMangling/simpleCapturedReceiverWithLabel.kt"); + } + + @Test + @TestMetadata("simpleCapturedReceiverWithParenthesis.kt") + public void testSimpleCapturedReceiverWithParenthesis() throws Exception { + runTest("compiler/testData/debug/localVariables/receiverMangling/simpleCapturedReceiverWithParenthesis.kt"); + } } @TestMetadata("compiler/testData/debug/localVariables/suspend") diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrAsmLikeInstructionListingTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrAsmLikeInstructionListingTestGenerated.java index 10e79362e40..c8cadd0b059 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrAsmLikeInstructionListingTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrAsmLikeInstructionListingTestGenerated.java @@ -81,11 +81,6 @@ public class IrAsmLikeInstructionListingTestGenerated extends AbstractIrAsmLikeI runTest("compiler/testData/codegen/asmLike/receiverMangling/inlineReceivers.kt"); } - @TestMetadata("innerClass.kt") - public void testInnerClass() throws Exception { - runTest("compiler/testData/codegen/asmLike/receiverMangling/innerClass.kt"); - } - @TestMetadata("localFunctions.kt") public void testLocalFunctions() throws Exception { runTest("compiler/testData/codegen/asmLike/receiverMangling/localFunctions.kt"); @@ -105,11 +100,6 @@ public class IrAsmLikeInstructionListingTestGenerated extends AbstractIrAsmLikeI public void testNonInlineReceivers_before() throws Exception { runTest("compiler/testData/codegen/asmLike/receiverMangling/nonInlineReceivers_before.kt"); } - - @TestMetadata("simple.kt") - public void testSimple() throws Exception { - runTest("compiler/testData/codegen/asmLike/receiverMangling/simple.kt"); - } } @TestMetadata("compiler/testData/codegen/asmLike/typeAnnotations")