diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java index fc41c3d93b3..2292949c7a3 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java @@ -1831,6 +1831,10 @@ public class ExpressionCodegen extends JetVisitor implem public void invokeMethodWithArguments(CallableMethod callableMethod, JetCallElement expression, StackValue receiver) { JetExpression calleeExpression = expression.getCalleeExpression(); + invokeMethodWithArguments(callableMethod, receiver, calleeExpression); + } + + public void invokeMethodWithArguments(CallableMethod callableMethod, StackValue receiver, JetExpression calleeExpression) { Call call = bindingContext.get(CALL, calleeExpression); ResolvedCall resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, calleeExpression); @@ -1839,6 +1843,7 @@ public class ExpressionCodegen extends JetVisitor implem invokeMethodWithArguments(callableMethod, resolvedCall, call, receiver); } + protected void invokeMethodWithArguments( @NotNull CallableMethod callableMethod, @NotNull ResolvedCall resolvedCall, diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/PsiMethodCall.java b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/PsiMethodCall.java index ff4daf80d43..84c006e610f 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/PsiMethodCall.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/PsiMethodCall.java @@ -26,6 +26,8 @@ import org.jetbrains.jet.codegen.OwnerKind; import org.jetbrains.jet.codegen.StackValue; import org.jetbrains.jet.codegen.state.GenerationState; import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor; +import org.jetbrains.jet.lang.psi.JetBinaryExpression; +import org.jetbrains.jet.lang.psi.JetCallElement; import org.jetbrains.jet.lang.psi.JetCallExpression; import org.jetbrains.jet.lang.psi.JetExpression; @@ -49,7 +51,11 @@ public class PsiMethodCall implements IntrinsicMethod { ) { final CallableMethod callableMethod = state.getTypeMapper().mapToCallableMethod(method, false, OwnerKind.IMPLEMENTATION); - codegen.invokeMethodWithArguments(callableMethod, (JetCallExpression) element, receiver); + if(element instanceof JetBinaryExpression) { + codegen.invokeMethodWithArguments(callableMethod, receiver, ((JetBinaryExpression)element).getOperationReference()); + } else { + codegen.invokeMethodWithArguments(callableMethod, (JetCallElement) element, receiver); + } return StackValue.onStack(callableMethod.getSignature().getAsmMethod().getReturnType()); } } diff --git a/compiler/testData/codegen/regressions/kt2929.kt b/compiler/testData/codegen/regressions/kt2929.kt new file mode 100644 index 00000000000..5e015e65900 --- /dev/null +++ b/compiler/testData/codegen/regressions/kt2929.kt @@ -0,0 +1,7 @@ +fun foo(): Int { + val a = "test" + val b = "test" + return a compareTo b +} + +fun box(): String = if(foo() == 0) "OK" else "Fail" diff --git a/compiler/tests/org/jetbrains/jet/codegen/FunctionGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/FunctionGenTest.java index 039b0758d20..cac49438062 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/FunctionGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/FunctionGenTest.java @@ -191,4 +191,8 @@ public class FunctionGenTest extends CodegenTestCase { public void testRemoveInIterator() throws Exception { blackBoxFileWithJava("functions/removeInIterator.kt"); } + + public void testKt2929() { + blackBoxFile("regressions/kt2929.kt"); + } }