Fix for KT-9828: DX error on MutableMap.MutableEntry<String, Int> deconstruction: attempt to set or access a value of type java.lang.Object using a local variable of type int.

#KT-9828 Fixed
This commit is contained in:
Michael Bogdanov
2015-10-30 13:59:10 +03:00
parent 9a8b73c5a5
commit 7ee42ab18d
3 changed files with 20 additions and 1 deletions
@@ -681,13 +681,14 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> 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<StackValue, StackValue> impleme
StackValue value = invokeFunction(call, resolvedCall, StackValue.local(loopParameterVar, asmElementType));
StackValue.local(componentVarIndex, componentAsmType).store(value, v);
v.visitLabel(variableStartLabel);
}
}
@@ -0,0 +1,11 @@
import java.util.*
fun box(): String {
val hashMap = HashMap<String, Int>()
hashMap.put("one", 1)
hashMap.put("two", 2)
for ((key, value) in hashMap) {
}
return "OK"
}
@@ -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");