remove attempt to optimize using 'if' statement as the last one in a loop which created far more problems that it fixed
#KT-1978 Fixed
This commit is contained in:
@@ -264,10 +264,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
Label elseLabel = new Label();
|
Label elseLabel = new Label();
|
||||||
condition.condJump(elseLabel, true, v); // == 0, i.e. false
|
condition.condJump(elseLabel, true, v); // == 0, i.e. false
|
||||||
|
|
||||||
Label end = continueLabel == null ? new Label() : continueLabel;
|
Label end = new Label();
|
||||||
|
|
||||||
if (continueLabel != null)
|
|
||||||
asmType = Type.VOID_TYPE;
|
|
||||||
|
|
||||||
gen(thenExpression, asmType);
|
gen(thenExpression, asmType);
|
||||||
|
|
||||||
@@ -276,10 +273,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
|
|
||||||
gen(elseExpression, asmType);
|
gen(elseExpression, asmType);
|
||||||
|
|
||||||
if (end != continueLabel)
|
v.mark(end);
|
||||||
v.mark(end);
|
|
||||||
else
|
|
||||||
v.goTo(end);
|
|
||||||
|
|
||||||
return StackValue.onStack(asmType);
|
return StackValue.onStack(asmType);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
fun aa(vararg a : String): String = a[0]
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
var result: String = ""
|
||||||
|
var i = 1
|
||||||
|
while (3 > i++) {
|
||||||
|
result = aa(if (true) "OK" else "fail")
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
@@ -126,4 +126,9 @@ public class VarArgTest extends CodegenTestCase {
|
|||||||
assertEquals("mama", Array.get(invoke, 0));
|
assertEquals("mama", Array.get(invoke, 0));
|
||||||
assertEquals("papa", Array.get(invoke, 1));
|
assertEquals("papa", Array.get(invoke, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testKt1978() {
|
||||||
|
createEnvironmentWithMockJdkAndIdeaAnnotations(CompilerSpecialMode.JDK_HEADERS);
|
||||||
|
blackBoxFile("regressions/kt1978.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user