diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index 1b86c8b7176..4bf346f2ba9 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -681,13 +681,14 @@ public class ExpressionCodegen extends KtVisitor impleme @SuppressWarnings("ConstantConditions") final Type componentAsmType = asmType(componentDescriptor.getReturnType()); final int componentVarIndex = myFrameMap.enter(componentDescriptor, componentAsmType); + final Label variableStartLabel = new Label(); scheduleLeaveVariable(new Runnable() { @Override public void run() { myFrameMap.leave(componentDescriptor); v.visitLocalVariable(componentDescriptor.getName().asString(), componentAsmType.getDescriptor(), null, - bodyStart, bodyEnd, + variableStartLabel, bodyEnd, componentVarIndex); } }); @@ -698,6 +699,7 @@ public class ExpressionCodegen extends KtVisitor impleme StackValue value = invokeFunction(call, resolvedCall, StackValue.local(loopParameterVar, asmElementType)); StackValue.local(componentVarIndex, componentAsmType).store(value, v); + v.visitLabel(variableStartLabel); } } diff --git a/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/kt9828.kt b/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/kt9828.kt new file mode 100644 index 00000000000..fc8cebd6c74 --- /dev/null +++ b/compiler/testData/codegen/boxWithStdlib/multiDeclForArray/kt9828.kt @@ -0,0 +1,11 @@ +import java.util.* + +fun box(): String { + val hashMap = HashMap() + hashMap.put("one", 1) + hashMap.put("two", 2) + for ((key, value) in hashMap) { + } + + return "OK" +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java index 867468e39c9..314a1995b5d 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java @@ -2524,6 +2524,12 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxWithStdlib/multiDeclForArray"), Pattern.compile("^(.+)\\.kt$"), true); } + @TestMetadata("kt9828.kt") + public void testKt9828() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/multiDeclForArray/kt9828.kt"); + doTestWithStdlib(fileName); + } + @TestMetadata("MultiDeclFor.kt") public void testMultiDeclFor() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/multiDeclForArray/MultiDeclFor.kt");