Skip to content

stored method interference graph #58948

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions base/Base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,9 @@ include("uuid.jl")
include("pkgid.jl")
include("toml_parser.jl")
include("linking.jl")
module StaticData
include("staticdata.jl")
end
include("loading.jl")

# BinaryPlatforms, used by Artifacts. Needs `Sort`.
Expand Down
8 changes: 5 additions & 3 deletions base/errorshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -465,14 +465,15 @@ function show_method_candidates(io::IO, ex::MethodError, kwargs=[])
line_score = Int[]
# These functions are special cased to only show if first argument is matched.
special = f === convert || f === getindex || f === setindex!
f isa Core.Builtin && return # `methods` isn't very useful for a builtin
funcs = Tuple{Any,Vector{Any}}[(f, arg_types_param)]

# An incorrect call method produces a MethodError for convert.
# It also happens that users type convert when they mean call. So
# pool MethodErrors for these two functions.
if f === convert && !isempty(arg_types_param)
at1 = arg_types_param[1]
if isType(at1) && !has_free_typevars(at1)
if isType(at1) && !has_free_typevars(at1) && at1.parameters[1] isa Type
push!(funcs, (at1.parameters[1], arg_types_param[2:end]))
end
end
Expand All @@ -494,8 +495,8 @@ function show_method_candidates(io::IO, ex::MethodError, kwargs=[])
end
sig0 = sig0::DataType
s1 = sig0.parameters[1]
if sig0 === Tuple || !isa(func, rewrap_unionall(s1, method.sig))
# function itself doesn't match or is a builtin
if !isa(func, rewrap_unionall(s1, method.sig))
# function itself doesn't match
continue
else
print(iob, " ")
Expand Down Expand Up @@ -640,6 +641,7 @@ function show_method_candidates(io::IO, ex::MethodError, kwargs=[])
println(io) # extra newline for spacing to stacktrace
end
end
nothing
end

# In case the line numbers in the source code have changed since the code was compiled,
Expand Down
8 changes: 3 additions & 5 deletions base/methodshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ end

# NOTE: second argument is deprecated and is no longer used
function kwarg_decl(m::Method, kwtype = nothing)
if m.sig !== Tuple # OpaqueClosure or Builtin
if !(m.sig === Tuple || m.sig <: Tuple{Core.Builtin, Vararg}) # OpaqueClosure or Builtin
kwtype = typeof(Core.kwcall)
sig = rewrap_unionall(Tuple{kwtype, NamedTuple, (unwrap_unionall(m.sig)::DataType).parameters...}, m.sig)
kwli = ccall(:jl_methtable_lookup, Any, (Any, UInt), sig, get_world_counter())
Expand Down Expand Up @@ -219,8 +219,7 @@ function show_method(io::IO, m::Method;
modulecolor = :light_black, digit_align_width = 1,
print_signature_only::Bool = get(io, :print_method_signature_only, false)::Bool)
tv, decls, file, line = arg_decl_parts(m)
sig = unwrap_unionall(m.sig)
if sig === Tuple
if m.sig <: Tuple{Core.Builtin, Vararg}
# Builtin
print(io, m.name, "(...)")
file = "none"
Expand Down Expand Up @@ -425,8 +424,7 @@ end
function show(io::IO, ::MIME"text/html", m::Method)
tv, decls, file, line = arg_decl_parts(m, true)
sig = unwrap_unionall(m.sig)
if sig === Tuple
# Builtin
if sig <: Tuple{Core.Builtin, Vararg}
print(io, m.name, "(...) in ", parentmodule(m))
return
end
Expand Down
10 changes: 1 addition & 9 deletions base/runtime_internals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1478,15 +1478,7 @@ end
function matches_to_methods(ms::Array{Any,1}, tn::Core.TypeName, mod)
# Lack of specialization => a comprehension triggers too many invalidations via _collect, so collect the methods manually
ms = Method[(ms[i]::Core.MethodMatch).method for i in 1:length(ms)]
# Remove shadowed methods with identical type signatures
prev = nothing
filter!(ms) do m
l = prev
repeated = (l isa Method && m.sig == l.sig)
prev = m
return !repeated
end
# Remove methods not part of module (after removing shadowed methods)
# Remove methods not part of module
mod === nothing || filter!(ms) do m
return parentmodule(m) ∈ mod
end
Expand Down
Loading