Skip to content
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

allow passing a module to methods #33403

Merged
merged 5 commits into from
Dec 11, 2019
Merged
Changes from 1 commit
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
Prev Previous commit
use nothing instead of () as a default value
  • Loading branch information
rfourquet committed Nov 16, 2019
commit fe3bc37df7c88e8be724e74e6b04defc5b253068
6 changes: 3 additions & 3 deletions base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ A list of modules can also be specified as an array or tuple.
At least Julia 1.4 is required for specifying a module.
"""
function methods(@nospecialize(f), @nospecialize(t),
@nospecialize(mod::Union{Module,AbstractArray{Module},Tuple{Vararg{Module}}}=()))
@nospecialize(mod::Union{Module,AbstractArray{Module},Tuple{Vararg{Module}},Nothing}=nothing))
if mod isa Module
mod = (mod,)
end
Expand All @@ -883,7 +883,7 @@ function methods(@nospecialize(f), @nospecialize(t),
end
t = to_tuple_type(t)
world = typemax(UInt)
MethodList(Method[m[3] for m in _methods(f, t, -1, world) if isempty(mod) || m[3].module in mod],
MethodList(Method[m[3] for m in _methods(f, t, -1, world) if mod === nothing || m[3].module in mod],
typeof(f).name.mt)
end

Expand All @@ -899,7 +899,7 @@ function methods_including_ambiguous(@nospecialize(f), @nospecialize(t))
end

function methods(@nospecialize(f),
@nospecialize(mod::Union{Module,AbstractArray{Module},Tuple{Vararg{Module}}}=()))
@nospecialize(mod::Union{Module,AbstractArray{Module},Tuple{Vararg{Module}},Nothing}=nothing))
# return all matches
return methods(f, Tuple{Vararg{Any}}, mod)
end
Expand Down