New, in Julia 1.7:
julia> Base.@aggressive_constprop constprop_unwrap(::Type{T}) where {T} = nameof(T)
constprop_unwrap (generic function with 1 method)
julia> @code_typed constprop_unwrap(Complex{Float32})
CodeInfo(
1 ─ return :Complex
) => Symbol
I’d do something like
@static if VERSION >= v"1.7.0-DEV.421"
Base.@aggressive_constprop constprop_unwrap(::Type{T}) where {T} = nameof(T)
else
@generated constprop_unwrap(::Type{T}) where {T} = QuoteNode(nameof(T))
end
to add support for older Julia versions.