From 5dc1651a448efae04d317dec8450c7a5835695ae Mon Sep 17 00:00:00 2001 From: Jinseong Jeon Date: Tue, 3 Mar 2020 15:11:45 -0800 Subject: [PATCH] JVM: missed line number for return expression. --- .../kotlin/codegen/ExpressionCodegen.java | 2 +- compiler/testData/debug/stepping/if.kt | 4 +- .../testData/debug/stepping/nestedInline.kt | 63 +++++++++++++++++++ .../IrSteppingTestGenerated.java | 6 ++ .../SteppingTestGenerated.java | 6 ++ 5 files changed, 77 insertions(+), 4 deletions(-) create mode 100644 compiler/testData/debug/stepping/nestedInline.kt diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index 79a8fe6f794..cdc29f3b67e 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -1656,7 +1656,7 @@ public class ExpressionCodegen extends KtVisitor impleme Label afterReturnLabel = new Label(); generateFinallyBlocksIfNeeded(returnType, returnKotlinType, afterReturnLabel); - + markLineNumber(expression, false); if (isNonLocalReturn) { generateGlobalReturnFlag(v, nonLocalReturn.labelName); v.visitInsn(returnType.getOpcode(Opcodes.IRETURN)); diff --git a/compiler/testData/debug/stepping/if.kt b/compiler/testData/debug/stepping/if.kt index 1fdeb9c2de2..a82f2377b3c 100644 --- a/compiler/testData/debug/stepping/if.kt +++ b/compiler/testData/debug/stepping/if.kt @@ -13,9 +13,6 @@ inline fun getB(): Int { return 1 } -// IGNORE_BACKEND: JVM_IR -// old backend is missing a line number after return from inline function call, actually IR backend results seems more right. - // LINENUMBERS // TestKt.box():4 // TestKt.box():13 @@ -24,3 +21,4 @@ inline fun getB(): Int { // TestKt.box():5 // TestKt.box():7 // TestKt.box():13 +// TestKt.box():7 diff --git a/compiler/testData/debug/stepping/nestedInline.kt b/compiler/testData/debug/stepping/nestedInline.kt new file mode 100644 index 00000000000..628d7d65357 --- /dev/null +++ b/compiler/testData/debug/stepping/nestedInline.kt @@ -0,0 +1,63 @@ +// This is same as kotlin/compiler/testData/codegen/boxInline/smap/smap.kt +// FILE: test.kt + +import builders.* + +inline fun test(): String { + var res = "Fail" + + html { + head { + res = "OK" + } + } + + return res +} + +fun box(): String { + var expected = test(); + + return expected +} + +// FILE: 1.kt + +package builders + +inline fun init(init: () -> Unit) { + init() +} + +inline fun initTag2(init: () -> Unit) { + val p = 1; + init() +} +//{val p = initTag2(init); return p} to remove difference in linenumber processing through MethodNode and MethodVisitor should be: = initTag2(init) +inline fun head(init: () -> Unit) { val p = initTag2(init); return p} + + +inline fun html(init: () -> Unit) { + return init(init) +} + +// LINENUMBERS +// TestKt.box():19 +// TestKt.box():7 +// TestKt.box():9 +// TestKt.box():18 +// TestKt.box():6 +// TestKt.box():10 +// TestKt.box():14 +// TestKt.box():10 +// TestKt.box():11 +// TestKt.box():11 +// TestKt.box():12 +// TestKt.box():12 +// TestKt.box():14 +// TestKt.box():13 +// TestKt.box():7 +// TestKt.box():18 +// TestKt.box():15 +// TestKt.box():19 +// TestKt.box():21 \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/debugInformation/IrSteppingTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/debugInformation/IrSteppingTestGenerated.java index c614deb883a..34370919897 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/debugInformation/IrSteppingTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/debugInformation/IrSteppingTestGenerated.java @@ -85,6 +85,12 @@ public class IrSteppingTestGenerated extends AbstractIrSteppingTest { runTest("compiler/testData/debug/stepping/namedCallableReference.kt"); } + @Test + @TestMetadata("nestedInline.kt") + public void testNestedInline() throws Exception { + runTest("compiler/testData/debug/stepping/nestedInline.kt"); + } + @Test @TestMetadata("recursion.kt") public void testRecursion() throws Exception { diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/debugInformation/SteppingTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/debugInformation/SteppingTestGenerated.java index 5ed1b014239..9e9dabbc9d7 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/debugInformation/SteppingTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/debugInformation/SteppingTestGenerated.java @@ -85,6 +85,12 @@ public class SteppingTestGenerated extends AbstractSteppingTest { runTest("compiler/testData/debug/stepping/namedCallableReference.kt"); } + @Test + @TestMetadata("nestedInline.kt") + public void testNestedInline() throws Exception { + runTest("compiler/testData/debug/stepping/nestedInline.kt"); + } + @Test @TestMetadata("recursion.kt") public void testRecursion() throws Exception {