diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java index 050bd7da483..a5ef0c787f7 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java @@ -1307,6 +1307,9 @@ public class ExpressionCodegen extends JetVisitor { else if(type.getSort() == Type.DOUBLE) { v.aconst(0d); } + else if(type.getSort() == Type.LONG) { + v.aconst(0l); + } else { v.iconst(0); } diff --git a/compiler/tests/org/jetbrains/jet/codegen/PrimitiveTypesTest.java b/compiler/tests/org/jetbrains/jet/codegen/PrimitiveTypesTest.java index d52a2e3c488..033f9c56b68 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/PrimitiveTypesTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/PrimitiveTypesTest.java @@ -284,4 +284,21 @@ public class PrimitiveTypesTest extends CodegenTestCase { public void testKt518 () throws Exception { blackBoxFile("regressions/kt518.jet"); } + + public void testKt665() throws Exception { + loadText("fun f(x: Long, zzz: Long = 1): Long\n" + + "{\n" + + " return if (x <= 1) zzz\n" + + " else f(x-1, x*zzz)\n" + + "}\n" + + "\n" + + "fun box() : String\n" + + "{\n" + + " val six: Long = 6;\n" + + " System.out?.println(f(six))\n" + + " return \"OK\"" + + "}"); + System.out.println(generateToText()); + blackBox(); + } }