Multi-decl for loops fixed
This commit is contained in:
@@ -500,8 +500,6 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
private void generateMultiVariables(int tmpParameterIndex, List<JetMultiDeclarationEntry> entries) {
|
||||
Type asmElementType = asmType(getElementType());
|
||||
for (JetMultiDeclarationEntry variableDeclaration : entries) {
|
||||
v.load(tmpParameterIndex, asmElementType);
|
||||
|
||||
final VariableDescriptor componentDescriptor = bindingContext.get(BindingContext.VARIABLE, variableDeclaration);
|
||||
|
||||
final Type componentAsmType = asmType(componentDescriptor.getReturnType());
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
class C(val i: Int) {
|
||||
fun component1() = i + 1
|
||||
fun component2() = i + 2
|
||||
}
|
||||
|
||||
fun doTest(l : java.util.ArrayList<C>): String {
|
||||
var s = ""
|
||||
for ((a, b) in l) {
|
||||
s += "$a:$b;"
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val l = java.util.ArrayList<C>()
|
||||
l.add(C(0))
|
||||
l.add(C(1))
|
||||
l.add(C(2))
|
||||
val s = doTest(l)
|
||||
return if (s == "1:2;2:3;3:4;") "OK" else "fail: $s"
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
class C(val i: Int) {
|
||||
}
|
||||
|
||||
fun C.component1() = i + 1
|
||||
fun C.component2() = i + 2
|
||||
|
||||
fun doTest(l : java.util.ArrayList<C>): String {
|
||||
var s = ""
|
||||
for ((a, b) in l) {
|
||||
s += "$a:$b;"
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val l = java.util.ArrayList<C>()
|
||||
l.add(C(0))
|
||||
l.add(C(1))
|
||||
l.add(C(2))
|
||||
val s = doTest(l)
|
||||
return if (s == "1:2;2:3;3:4;") "OK" else "fail: $s"
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
class C(val i: Int) {
|
||||
}
|
||||
|
||||
class M {
|
||||
fun C.component1() = i + 1
|
||||
fun C.component2() = i + 2
|
||||
|
||||
fun doTest(l : java.util.ArrayList<C>): String {
|
||||
var s = ""
|
||||
for ((a, b) in l) {
|
||||
s += "$a:$b;"
|
||||
}
|
||||
return s
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val l = java.util.ArrayList<C>()
|
||||
l.add(C(0))
|
||||
l.add(C(1))
|
||||
l.add(C(2))
|
||||
val s = M().doTest(l)
|
||||
return if (s == "1:2;2:3;3:4;") "OK" else "fail: $s"
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
class C(val i: Int) {
|
||||
}
|
||||
|
||||
class M {
|
||||
fun C.component1() = i + 1
|
||||
fun C.component2() = i + 2
|
||||
}
|
||||
|
||||
fun M.doTest(l : java.util.ArrayList<C>): String {
|
||||
var s = ""
|
||||
for ((a, b) in l) {
|
||||
s += "$a:$b;"
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val l = java.util.ArrayList<C>()
|
||||
l.add(C(0))
|
||||
l.add(C(1))
|
||||
l.add(C(2))
|
||||
val s = M().doTest(l)
|
||||
return if (s == "1:2;2:3;3:4;") "OK" else "fail: $s"
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
class C(val i: Int) {
|
||||
fun component1() = i + 1
|
||||
fun component2() = i + 2
|
||||
}
|
||||
|
||||
fun doTest(l : java.util.ArrayList<C>): String {
|
||||
var s = ""
|
||||
for ((a, b) in l) {
|
||||
s += {"$a:$b;"}()
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val l = java.util.ArrayList<C>()
|
||||
l.add(C(0))
|
||||
l.add(C(1))
|
||||
l.add(C(2))
|
||||
val s = doTest(l)
|
||||
return if (s == "1:2;2:3;3:4;") "OK" else "fail: $s"
|
||||
}
|
||||
@@ -37,6 +37,31 @@ public class MultiDeclTestGenerated extends AbstractMultiDeclTestCase {
|
||||
blackBoxFileByFullPath("compiler/testData/codegen/multiDecl/ComplexInitializer.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("MultiDeclFor.kt")
|
||||
public void testMultiDeclFor() throws Exception {
|
||||
blackBoxFileByFullPath("compiler/testData/codegen/multiDecl/MultiDeclFor.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("MultiDeclForComponentExtensions.kt")
|
||||
public void testMultiDeclForComponentExtensions() throws Exception {
|
||||
blackBoxFileByFullPath("compiler/testData/codegen/multiDecl/MultiDeclForComponentExtensions.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("MultiDeclForComponentMemberExtensions.kt")
|
||||
public void testMultiDeclForComponentMemberExtensions() throws Exception {
|
||||
blackBoxFileByFullPath("compiler/testData/codegen/multiDecl/MultiDeclForComponentMemberExtensions.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("MultiDeclForComponentMemberExtensionsInExtensionFunction.kt")
|
||||
public void testMultiDeclForComponentMemberExtensionsInExtensionFunction() throws Exception {
|
||||
blackBoxFileByFullPath("compiler/testData/codegen/multiDecl/MultiDeclForComponentMemberExtensionsInExtensionFunction.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("MultiDeclForValCaptured.kt")
|
||||
public void testMultiDeclForValCaptured() throws Exception {
|
||||
blackBoxFileByFullPath("compiler/testData/codegen/multiDecl/MultiDeclForValCaptured.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("SimpleVals.kt")
|
||||
public void testSimpleVals() throws Exception {
|
||||
blackBoxFileByFullPath("compiler/testData/codegen/multiDecl/SimpleVals.kt");
|
||||
|
||||
Reference in New Issue
Block a user