invoke method

Object? invoke(
  1. Object proxy,
  2. Object target,
  3. int index,
  4. List<Object?> arguments,
  5. Object? call(
    1. List<Object?> arguments
    ),
)

Calls the synchronous member index through its advice and returns the result.

arguments are the caller's arguments; call runs the real member with the arguments the advice passes on. Without matching advice, call runs directly. A call a subclass proxy makes on itself from its own code skips the advice, as a this call does in Spring.

Implementation

Object? invoke(
  Object proxy,
  Object target,
  int index,
  List<Object?> arguments,
  Object? Function(List<Object?> arguments) call,
) {
  if (_isSelfCall(proxy, target)) {
    return call(arguments);
  }
  final body = identical(proxy, target)
      ? (List<Object?> args) => runProxyBody(proxy, () => call(args))
      : call;
  return runWithCurrentProxy(proxy, () {
    final chain = chainFor(index);
    if (chain.isEmpty) {
      return body(arguments);
    }
    return _Invocation(
      proxy,
      target,
      signatures[index],
      [...arguments],
      chain,
      0,
      body,
    ).proceed();
  });
}