Fix compilation of infix calls (KT-2929)
#KT-2929 Fixed
This commit is contained in:
committed by
Dmitry Jemerov
parent
c4bda6a260
commit
81de3cd46a
@@ -1831,6 +1831,10 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
|||||||
|
|
||||||
public void invokeMethodWithArguments(CallableMethod callableMethod, JetCallElement expression, StackValue receiver) {
|
public void invokeMethodWithArguments(CallableMethod callableMethod, JetCallElement expression, StackValue receiver) {
|
||||||
JetExpression calleeExpression = expression.getCalleeExpression();
|
JetExpression calleeExpression = expression.getCalleeExpression();
|
||||||
|
invokeMethodWithArguments(callableMethod, receiver, calleeExpression);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void invokeMethodWithArguments(CallableMethod callableMethod, StackValue receiver, JetExpression calleeExpression) {
|
||||||
Call call = bindingContext.get(CALL, calleeExpression);
|
Call call = bindingContext.get(CALL, calleeExpression);
|
||||||
ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, calleeExpression);
|
ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, calleeExpression);
|
||||||
|
|
||||||
@@ -1839,6 +1843,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
|||||||
invokeMethodWithArguments(callableMethod, resolvedCall, call, receiver);
|
invokeMethodWithArguments(callableMethod, resolvedCall, call, receiver);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void invokeMethodWithArguments(
|
protected void invokeMethodWithArguments(
|
||||||
@NotNull CallableMethod callableMethod,
|
@NotNull CallableMethod callableMethod,
|
||||||
@NotNull ResolvedCall<? extends CallableDescriptor> resolvedCall,
|
@NotNull ResolvedCall<? extends CallableDescriptor> resolvedCall,
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ import org.jetbrains.jet.codegen.OwnerKind;
|
|||||||
import org.jetbrains.jet.codegen.StackValue;
|
import org.jetbrains.jet.codegen.StackValue;
|
||||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||||
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
|
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.JetCallExpression;
|
||||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||||
|
|
||||||
@@ -49,7 +51,11 @@ public class PsiMethodCall implements IntrinsicMethod {
|
|||||||
) {
|
) {
|
||||||
final CallableMethod callableMethod =
|
final CallableMethod callableMethod =
|
||||||
state.getTypeMapper().mapToCallableMethod(method, false, OwnerKind.IMPLEMENTATION);
|
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());
|
return StackValue.onStack(callableMethod.getSignature().getAsmMethod().getReturnType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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"
|
||||||
@@ -191,4 +191,8 @@ public class FunctionGenTest extends CodegenTestCase {
|
|||||||
public void testRemoveInIterator() throws Exception {
|
public void testRemoveInIterator() throws Exception {
|
||||||
blackBoxFileWithJava("functions/removeInIterator.kt");
|
blackBoxFileWithJava("functions/removeInIterator.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testKt2929() {
|
||||||
|
blackBoxFile("regressions/kt2929.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user