JVM: missed line number for return expression.

This commit is contained in:
Jinseong Jeon
2020-03-03 15:11:45 -08:00
committed by max-kammerer
parent c29f76580c
commit 5dc1651a44
5 changed files with 77 additions and 4 deletions
@@ -1656,7 +1656,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
Label afterReturnLabel = new Label();
generateFinallyBlocksIfNeeded(returnType, returnKotlinType, afterReturnLabel);
markLineNumber(expression, false);
if (isNonLocalReturn) {
generateGlobalReturnFlag(v, nonLocalReturn.labelName);
v.visitInsn(returnType.getOpcode(Opcodes.IRETURN));
+1 -3
View File
@@ -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
+63
View File
@@ -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
@@ -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 {
@@ -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 {