Closed
Description
openedon Sep 18, 2017
I was informed in #23471 that functions that accept ::Type
(vs. ::Type{T} where T
) do not specialize on that argument. However, @code_warntype
shows a specialized function body (on 0.6):
julia> foo(t::Type) = t
foo (generic function with 1 method)
julia> @code_warntype foo(Int)
Variables:
#self#::#foo
t::Type{Int64}
Body:
begin
return t::Type{Int64}
end::Type{Int64}
This is confirmed by looking at the specializations:
julia> foo(Int) # run it normally
Int64
julia> Base.visit(println, methods(foo).ms[1].specializations)
MethodInstance for foo(::Type{T} where T) # specialization triggered by foo(Int)
MethodInstance for foo(::Type{Int64}) # specialization triggered by @code_warntype
I'm guessing that the correct outcome is this:
julia> code_warntype(foo, (Type{T} where T,))
Variables:
#self#::#foo
t::Type{T} where T
Body:
begin
return t::Type{T} where T
end::Type{T} where T
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Metadata
Assignees
Labels
No labels