Skip to content

Commit

Permalink
improve inferrability of loading.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk committed May 13, 2023
1 parent 0a05a5b commit 7c24cc6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
13 changes: 8 additions & 5 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ function manifest_deps_get(env::String, where::PkgId, name::String)::Union{Nothi
exts = get(d, "extensions", nothing)::Union{Dict{String, Any}, Nothing}
if exts !== nothing
# Check if `where` is an extension of the project
if where.name in keys(exts) && where.uuid == uuid5(proj.uuid, where.name)
if where.name in keys(exts) && where.uuid == uuid5(proj.uuid::String, where.name)
# Extensions can load weak deps...
weakdeps = get(d, "weakdeps", nothing)::Union{Dict{String, Any}, Nothing}
if weakdeps !== nothing
Expand Down Expand Up @@ -1209,7 +1209,9 @@ function insert_extension_triggers(env::String, pkg::PkgId)::Union{Nothing,Missi
extensions = get(d_proj, "extensions", nothing)::Union{Nothing, Dict{String, Any}}
extensions === nothing && return
weakdeps === nothing && return
return _insert_extension_triggers(pkg, extensions, weakdeps)
if weakdeps isa Dict{String, Any}
return _insert_extension_triggers(pkg, extensions, weakdeps)
end
end

# Now look in manifest
Expand All @@ -1231,7 +1233,7 @@ function insert_extension_triggers(env::String, pkg::PkgId)::Union{Nothing,Missi
return _insert_extension_triggers(pkg, extensions, weakdeps)
end

d_weakdeps = Dict{String, String}()
d_weakdeps = Dict{String, Any}()
for (dep_name, entries) in d
dep_name in weakdeps || continue
entries::Vector{Any}
Expand All @@ -1251,8 +1253,9 @@ function insert_extension_triggers(env::String, pkg::PkgId)::Union{Nothing,Missi
return nothing
end

function _insert_extension_triggers(parent::PkgId, extensions::Dict{String, <:Any}, weakdeps::Dict{String, <:Any})
for (ext::String, triggers::Union{String, Vector{String}}) in extensions
function _insert_extension_triggers(parent::PkgId, extensions::Dict{String, Any}, weakdeps::Dict{String, Any})
for (ext, triggers) in extensions
triggers = triggers::Union{String, Vector{String}}
triggers isa String && (triggers = [triggers])
id = PkgId(uuid5(parent.uuid, ext), ext)
if id in keys(EXT_PRIMED) || haskey(Base.loaded_modules, id)
Expand Down
3 changes: 2 additions & 1 deletion base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,8 @@ function may_invoke_generator(method::Method, @nospecialize(atype), sparams::Sim
generator = method.generator
isa(generator, Core.GeneratedFunctionStub) || return false
gen_mthds = _methods_by_ftype(Tuple{typeof(generator.gen), Vararg{Any}}, 1, method.primary_world)
(gen_mthds isa Vector && length(gen_mthds) == 1) || return false
gen_mthds isa Vector || return false
length(gen_mthds) == 1 || return false

generator_method = first(gen_mthds).method
nsparams = length(sparams)
Expand Down

0 comments on commit 7c24cc6

Please sign in to comment.