diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java index ff450c5ae7d..fa20bdd5df7 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java @@ -264,10 +264,7 @@ public class ExpressionCodegen extends JetVisitor { Label elseLabel = new Label(); condition.condJump(elseLabel, true, v); // == 0, i.e. false - Label end = continueLabel == null ? new Label() : continueLabel; - - if (continueLabel != null) - asmType = Type.VOID_TYPE; + Label end = new Label(); gen(thenExpression, asmType); @@ -276,10 +273,7 @@ public class ExpressionCodegen extends JetVisitor { gen(elseExpression, asmType); - if (end != continueLabel) - v.mark(end); - else - v.goTo(end); + v.mark(end); return StackValue.onStack(asmType); } diff --git a/compiler/testData/codegen/regressions/kt1978.kt b/compiler/testData/codegen/regressions/kt1978.kt new file mode 100644 index 00000000000..6d27ec3a311 --- /dev/null +++ b/compiler/testData/codegen/regressions/kt1978.kt @@ -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 +} diff --git a/compiler/tests/org/jetbrains/jet/codegen/VarArgTest.java b/compiler/tests/org/jetbrains/jet/codegen/VarArgTest.java index 5be1db68f10..1f05ecf73fe 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/VarArgTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/VarArgTest.java @@ -126,4 +126,9 @@ public class VarArgTest extends CodegenTestCase { assertEquals("mama", Array.get(invoke, 0)); assertEquals("papa", Array.get(invoke, 1)); } + + public void testKt1978() { + createEnvironmentWithMockJdkAndIdeaAnnotations(CompilerSpecialMode.JDK_HEADERS); + blackBoxFile("regressions/kt1978.kt"); + } }