final Expression right,
final MethodInfo method) {
assert method != null;
final ParameterList parameters = method.getParameters();
if (parameters.size() != 2) {
throw Error.incorrectNumberOfMethodCallArguments(method);
}
final Type returnType = method.getReturnType();
final Type leftParameterType = parameters.get(0).getParameterType();
final Type rightParameterType = parameters.get(1).getParameterType();
final Type leftType = left.getType();
final Type rightType = right.getType();
if (parameterIsAssignable(parameters.get(0).getParameterType(), leftType) &&
parameterIsAssignable(parameters.get(1).getParameterType(), rightType)) {
return new MethodBinaryExpression(binaryType, left, right, returnType, method);
}
throw Error.methodBasedOperatorMustHaveValidReturnType(binaryType, method);