dispatchToHandler = (
    handlerName,
    handler,
    operation,
    o,
    opArgs,
    returnedP,
  ) => {
    let actualOp = operation;

    const matchSendOnly = SEND_ONLY_RE.exec(actualOp);

    const makeResult = result => (matchSendOnly ? undefined : result);

    if (matchSendOnly) {
      // We don't specify the resulting promise if it is sendonly.
      returnedP = undefined;
    }

    if (matchSendOnly && typeof handler[actualOp] !== 'function') {
      // Substitute for sendonly with the corresponding non-sendonly operation.
      actualOp = /** @type {'get' | 'applyMethod' | 'applyFunction'} */ (
        matchSendOnly[1]
      );
    }

    // Fast path: just call the actual operation.
    const hfn = handler[actualOp];
    if (typeof hfn === 'function') {
      const result = apply(hfn, handler, [o, ...opArgs, returnedP]);
      return makeResult(result);
    }

    if (actualOp === 'applyMethod') {
      // Compose a missing applyMethod by get followed by applyFunction.
      const [prop, args] = opArgs;
      const getResultP = handle(
        o,
        'get',
        // The argument to 'get' is a string or symbol.
        [coerceToObjectProperty(prop)],
        undefined,
      );
      return makeResult(handle(getResultP, 'applyFunction', [args], returnedP));
    }

    // BASE CASE: applyFunction bottoms out into applyMethod, if it exists.
    if (actualOp === 'applyFunction') {
      const amfn = handler.applyMethod;
      if (typeof amfn === 'function') {
        // Downlevel a missing applyFunction to applyMethod with undefined name.
        const [args] = opArgs;
        const result = apply(amfn, handler, [o, undefined, [args], returnedP]);
        return makeResult(result);
      }
    }

    throw assert.fail(
      X`${q(handlerName)} is defined but has no methods needed for ${q(
        operation,
      )} (has ${q(getMethodNames(handler))})`,
      TypeError,
    );
  }
@param {string} handlerName
@param {Handler<any>} handler
@param {keyof Handler<any>} operation
@param {any} o
@param {any[]} opArgs
@param {Promise<unknown>} [returnedP]
@returns {any}