Back-end: correct indexes of local variables for double and long

#KT-3033 Fixed
This commit is contained in:
Natalia.Ukhorskaya
2012-11-12 15:03:54 +04:00
parent 94fbf2bdf4
commit b5a3486131
4 changed files with 37 additions and 15 deletions
@@ -688,10 +688,11 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
iv.getfield(JvmClassName.byType(classAsmType).getInternalName(), CAPTURED_THIS_FIELD, type.getDescriptor());
}
int parameterIndex = 0;
int parameterIndex = 1; // localVariable 0 = this
for (ValueParameterDescriptor parameterDescriptor : function.getValueParameters()) {
iv.load(parameterIndex + 1, typeMapper.mapType(parameterDescriptor.getType()));
parameterIndex++;
Type type = typeMapper.mapType(parameterDescriptor.getType());
iv.load(parameterIndex, type);
parameterIndex += type.getSize();
}
String constructorJvmDescriptor = typeMapper.mapToCallableMethod(constructor).getSignature().getAsmMethod().getDescriptor();
@@ -0,0 +1,6 @@
data class someClass(val a: Double, val b: Double)
// METHOD : copy(DD)LsomeClass;
// VARIABLE : NAME=this TYPE=LsomeClass; INDEX=0
// VARIABLE : NAME=a TYPE=D INDEX=1
// VARIABLE : NAME=b TYPE=D INDEX=3
@@ -0,0 +1,10 @@
data class A(val a: Double, val b: Double)
fun box() : String {
val a = A(1.0, 1.0)
val b = a.copy()
if (b.a == 1.0 && b.b == 1.0) {
return "OK"
}
return "fail"
}
@@ -84,8 +84,7 @@ public class DataClassCodegenTestGenerated extends AbstractDataClassCodegenTest
@TestMetadata("compiler/testData/codegen/dataClasses/copy")
public static class Copy extends AbstractDataClassCodegenTest {
public void testAllFilesPresentInCopy() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.codegen.AbstractDataClassCodegenTest",
new File("compiler/testData/codegen/dataClasses/copy"), "kt", true);
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.codegen.AbstractDataClassCodegenTest", new File("compiler/testData/codegen/dataClasses/copy"), "kt", true);
}
@TestMetadata("constructorWithDefaultParam.kt")
@@ -93,6 +92,21 @@ public class DataClassCodegenTestGenerated extends AbstractDataClassCodegenTest
blackBoxFileByFullPath("compiler/testData/codegen/dataClasses/copy/constructorWithDefaultParam.kt");
}
@TestMetadata("copyInNestedDataClass.kt")
public void testCopyInNestedDataClass() throws Exception {
blackBoxFileByFullPath("compiler/testData/codegen/dataClasses/copy/copyInNestedDataClass.kt");
}
@TestMetadata("copyInObjectNestedDataClass.kt")
public void testCopyInObjectNestedDataClass() throws Exception {
blackBoxFileByFullPath("compiler/testData/codegen/dataClasses/copy/copyInObjectNestedDataClass.kt");
}
@TestMetadata("kt3033.kt")
public void testKt3033() throws Exception {
blackBoxFileByFullPath("compiler/testData/codegen/dataClasses/copy/kt3033.kt");
}
@TestMetadata("paramWithoutProperty.kt")
public void testParamWithoutProperty() throws Exception {
blackBoxFileByFullPath("compiler/testData/codegen/dataClasses/copy/paramWithoutProperty.kt");
@@ -112,16 +126,7 @@ public class DataClassCodegenTestGenerated extends AbstractDataClassCodegenTest
public void testWithGenericParameter() throws Exception {
blackBoxFileByFullPath("compiler/testData/codegen/dataClasses/copy/withGenericParameter.kt");
}
@TestMetadata("copyInNestedDataClass.kt")
public void testCopyInNestedClasses() throws Exception {
blackBoxFileByFullPath("compiler/testData/codegen/dataClasses/copy/copyInNestedDataClass.kt");
}
@TestMetadata("copyInObjectNestedDataClass.kt")
public void testCopyInObjectNestedClasses() throws Exception {
blackBoxFileByFullPath("compiler/testData/codegen/dataClasses/copy/copyInObjectNestedDataClass.kt");
}
}
@TestMetadata("compiler/testData/codegen/dataClasses/equals")