Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add some unnecessary MethodError restrictions for Type (JuliaLang#43087)
The previous `@nospecialize(::Type)` dispatch signatures actually caused the following kinds of dynamic dispatches: ```julia julia> using JET julia> report_opt((Vector{Any},)) do ts isbitstype(ts[1]) end ═════ 1 possible error found ═════ ┌ @ REPL[3]:2 Main.isbitstype(%1) │ runtime dispatch detected: Main.isbitstype(%1::Any) └───────────── ``` This commit also adds an overload of `emptymutable(::IdSet)`, which eliminates the dynamic dispatch below: ```julia julia> report_opt((Base.IdSet{Any}, Base.IdSet{Any}); annotate_types=true) do s1, s2 s1 ∪ s2 end ═════ 2 possible errors found ═════ ┌ @ REPL[3]:2 Main.∪(s1::Base.IdSet{Any}, s2::Base.IdSet{Any}) │┌ @ abstractset.jl:48 Base.union!(Core.tuple(Base.emptymutable(s::Base.IdSet{Any}, Base.promote_eltype(Core.tuple(s::Base.IdSet{Any})::Tuple{Base.IdSet{Any}}, sets::Tuple{Base.IdSet{Any}}...)::Type{Any})::Set{Any}, s::Base.IdSet{Any})::Tuple{Set{Any}, Base.IdSet{Any}}, sets::Tuple{Base.IdSet{Any}}...) ││┌ @ abstractset.jl:76 Base.union!(s::Set{Any}, x::Base.IdSet{Any}) │││┌ @ abstractset.jl:93 Base.sizehint!(s::Set{Any}, Base.+(Base.length(s::Set{Any})::Int64, Core.typeassert(Base.Int(Base.length(itr::Base.IdSet{Any})::Int64)::Int64, Base.Int)::Int64)::Int64) ││││┌ @ set.jl:84 Base.sizehint!(Base.getproperty(s::Set{Any}, :dict::Symbol)::Dict{Any, Nothing}, newsz::Int64) │││││┌ @ dict.jl:244 Base.rehash!(d::Dict{Any, Nothing}, newsz::Int64) ││││││┌ @ dict.jl:203 Base.hashindex(%231::Any, %20::Int64) │││││││ runtime dispatch detected: Base.hashindex(%231::Any, %20::Int64) ││││││└─────────────── │││┌ @ abstractset.jl:95 Base.push!(s::Set{Any}, %62::Any) ││││ runtime dispatch detected: Base.push!(s::Set{Any}, %62::Any) │││└───────────────────── ```
- Loading branch information