Is there a way to force a wrong dispatch for test purposes?

I believe you’re looking for invoke.

  invoke(f, argtypes::Type, args...; kwargs...)

  Invoke a method for the given generic function f matching the specified types argtypes on the specified
  arguments args and passing the keyword arguments kwargs. The arguments args must conform with the
  specified types in argtypes, i.e. conversion is not automatically performed. This method allows invoking a
  method other than the most specific matching method, which is useful when the behavior of a more general
  definition is explicitly needed (often as part of the implementation of a more specific method of the same
  function).
4 Likes