How to use `which`

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