How to use `which`

The manual for the which function gives the following 3 variants:

help?> which
search: which @which

  which(f, types)

  Returns the method of f (a Method object) that would be called for arguments of the given types.

  If types is an abstract type, then the method that would be called by invoke is returned.

  See also: parentmodule, and @which and @edit in InteractiveUtils.

  ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

  which(types::Type{<:Tuple})

  Returns the method that would be called by the given type signature (as a tuple type).

  ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

  which(module, symbol)

  Return the module in which the binding for the variable referenced by symbol in module was created.

Can anyone give an example of using the second variant? I have tried

which(Type{Tuple{Function,Vector}})

which results in a MethodError.

It is a bit confusing, but there are two key facts that should clear things up. First, the type signature ::Type{T} wants an instance of T.

julia> T = Type{Int}

julia> typeof(T)
DataType

julia> T isa Type{T}
true

julia> Type{T} isa Type{Type{T}}
true

Second, the method requires the first parameter of this type to be the caller.

julia> f(::Int, ::Float64) = 1;

julia> which(Tuple{typeof(f), Int, Float64})
f(::Int64, ::Float64)
     @ Main REPL[14]:1
3 Likes