sig_params(t::UnionAll) = sig_params(t.body)
sig_params(t::DataType) = t.parameters[2:end]
abstract type AT2{T<:Real} end
f(x::AT2{Float64}) = "AT2{Float64}"
f(x::T) where T<:AT2 = "T<:AT2"
julia> methods(f)
# 2 methods for generic function "f":
[1] f(x::AT2{Float64}) in Main at REPL[4]:1
[2] f(x::T) where T<:AT2 in Main at REPL[5]:1
julia> sig = methods(f).ms[2].sig
Tuple{typeof(f),T} where T<:AT2
julia> methods(f,sig_params(sig))
# 2 methods for generic function "f":
[1] f(x::AT2{Float64}) in Main at REPL[4]:1
[2] f(x::T) where T<:AT2 in Main at REPL[5]:1
julia> code_lowered(f,sig_params(sig))
2-element Array{Core.CodeInfo,1}:
CodeInfo(
1 ─ return "AT2{Float64}"
)
CodeInfo(
1 ─ return "T<:AT2"
)
what is the proper signature to query only the second method “[2] f(x::T) where T<:AT2” ?
one more question, the results of methods and code_lowered, do they correspond one to one always with proper order?
thanks