Do not store null for temporary in destructuring assignment

#KT-19256 Fixed Target versions 1.1.5
This commit is contained in:
Dmitry Petrov
2017-07-26 17:31:58 +03:00
parent b867c46f72
commit c9ad290ad5
3 changed files with 11 additions and 4 deletions
@@ -3457,10 +3457,6 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
initializeDestructuringDeclarationVariables(multiDeclaration, initializerAsReceiver, local, asProperty);
if (initializerAsmType.getSort() == Type.OBJECT || initializerAsmType.getSort() == Type.ARRAY) {
v.aconst(null);
v.store(tempVarIndex, initializerAsmType);
}
myFrameMap.leaveTemp(initializerAsmType);
return StackValue.none();
@@ -0,0 +1,5 @@
fun test(p: Pair<Int, Int>) {
val (x, y) = p
}
// 0 ACONST_NULL
@@ -132,6 +132,12 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
doTest(fileName);
}
@TestMetadata("doNotStoreNullForTmpInDestructuring.kt")
public void testDoNotStoreNullForTmpInDestructuring() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/doNotStoreNullForTmpInDestructuring.kt");
doTest(fileName);
}
@TestMetadata("doNotStoreNullsForCapturedVars.kt")
public void testDoNotStoreNullsForCapturedVars() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/doNotStoreNullsForCapturedVars.kt");