diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/LocalVarRemapper.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/LocalVarRemapper.java index e69c30cfa30..05d3a3c69b2 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/LocalVarRemapper.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/LocalVarRemapper.java @@ -94,8 +94,8 @@ public class LocalVarRemapper { public void visitLocalVariable(String name, String desc, String signature, Label start, Label end, int index, MethodVisitor mv) { RemapInfo info = doRemap(index); - //add entries only for shifted vars - if (SHIFT == info.status) { + //add entries only for shifted vars or remapped to locals + if (SHIFT == info.status || REMAPPED == info.status && info.value instanceof StackValue.Local) { int newIndex = ((StackValue.Local) info.value).index; mv.visitLocalVariable(name, desc, signature, start, end, newIndex); } diff --git a/compiler/testData/codegen/bytecodeText/inline/remappedLocalVar.kt b/compiler/testData/codegen/bytecodeText/inline/remappedLocalVar.kt new file mode 100644 index 00000000000..fa4201b9b37 --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/inline/remappedLocalVar.kt @@ -0,0 +1,11 @@ +inline fun watch(p: String, f: (String) -> Int) { + f(p) +} + +fun main(args: Array) { + val local = "mno" + watch(local) { it.length } +} + +// 2 LOCALVARIABLE p +// 1 LOCALVARIABLE p\$iv \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java index 4285f440db9..597fc1d6dfe 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java @@ -760,6 +760,12 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest { doTest(fileName); } + @TestMetadata("remappedLocalVar.kt") + public void testRemappedLocalVar() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/inline/remappedLocalVar.kt"); + doTest(fileName); + } + @TestMetadata("removedFinallyMarkers.kt") public void testRemovedFinallyMarkers() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/inline/removedFinallyMarkers.kt"); diff --git a/idea/testData/debugger/tinyApp/outs/remappedParameterInInline.out b/idea/testData/debugger/tinyApp/outs/remappedParameterInInline.out new file mode 100644 index 00000000000..d02d5b11259 --- /dev/null +++ b/idea/testData/debugger/tinyApp/outs/remappedParameterInInline.out @@ -0,0 +1,8 @@ +LineBreakpoint created at remappedParameterInInline.kt:7 +!JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !OUTPUT_PATH!;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! remappedParameterInInline.RemappedParameterInInlineKt +Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' +remappedParameterInInline.kt:7 +Compile bytecode for p +Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' + +Process finished with exit code 0 diff --git a/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/remappedParameterInInline.kt b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/remappedParameterInInline.kt new file mode 100644 index 00000000000..b82643834bc --- /dev/null +++ b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/remappedParameterInInline.kt @@ -0,0 +1,14 @@ +package remappedParameterInInline + +inline fun watch(p: String, f: (String) -> Int) { + // EXPRESSION: p + // RESULT: "mno": Ljava/lang/String; + //Breakpoint! + f(p) +} + +fun main(args: Array) { + val local = "mno" + watch(local) { it.length } +} +