From 082fdebaaee5600c26a246ed22759ae8b609d4a1 Mon Sep 17 00:00:00 2001 From: Alex Tkachman Date: Fri, 17 Feb 2012 09:08:41 -0500 Subject: [PATCH] KT-723 optional boxing after call to .inc() --- .../src/org/jetbrains/jet/codegen/ExpressionCodegen.java | 6 ++++-- compiler/testData/codegen/regressions/kt723.kt | 8 ++++++++ .../tests/org/jetbrains/jet/codegen/ClassGenTest.java | 4 ++++ 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 compiler/testData/codegen/regressions/kt723.kt diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java index f4f736dc200..f44633d074e 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java @@ -2159,8 +2159,10 @@ public class ExpressionCodegen extends JetVisitor { case -1: throw new UnsupportedOperationException(); } - - ((CallableMethod)callable).invoke(v); + + CallableMethod callableMethod = (CallableMethod) callable; + callableMethod.invoke(v); + StackValue.onStack(callableMethod.getSignature().getAsmMethod().getReturnType()).put(value.type, v); value.store(v); return StackValue.onStack(type); } diff --git a/compiler/testData/codegen/regressions/kt723.kt b/compiler/testData/codegen/regressions/kt723.kt new file mode 100644 index 00000000000..991d6b2772d --- /dev/null +++ b/compiler/testData/codegen/regressions/kt723.kt @@ -0,0 +1,8 @@ +fun Int?.inc() : Int { if (this != null) return this.inc() else throw NullPointerException() } + +public fun box() : String { + var i : Int? = 10 + val j = i++ + + return if(j==10 && 11 == i) "OK" else "fail" +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/jet/codegen/ClassGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/ClassGenTest.java index 87c743bff04..9cc0d7056f8 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/ClassGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/ClassGenTest.java @@ -285,4 +285,8 @@ public class ClassGenTest extends CodegenTestCase { public void testKt1213() throws Exception { // blackBoxFile("regressions/kt1213.kt"); } + + public void testKt723() throws Exception { + blackBoxFile("regressions/kt723.kt"); + } }