@@ -849,14 +849,19 @@ Return the method table for `f`.
849
849
850
850
If `types` is specified, return an array of methods whose types match.
851
851
If `module` is specified, return an array of methods defined in this module.
852
+ A list of modules can also be specified as an array or tuple.
852
853
"""
853
- function methods (@nospecialize (f), @nospecialize (t), mod:: Union{Module,Nothing} = nothing )
854
+ function methods (@nospecialize (f), @nospecialize (t),
855
+ @nospecialize (mod:: Union{Module,AbstractArray{Module},Tuple{Vararg{Module}}} = ()))
856
+ if mod isa Module
857
+ mod = (mod,)
858
+ end
854
859
if isa (f, Core. Builtin)
855
860
throw (ArgumentError (" argument is not a generic function" ))
856
861
end
857
862
t = to_tuple_type (t)
858
863
world = typemax (UInt)
859
- MethodList (Method[m[3 ] for m in _methods (f, t, - 1 , world) if mod === nothing || m[3 ]. module == mod],
864
+ MethodList (Method[m[3 ] for m in _methods (f, t, - 1 , world) if isempty ( mod) || m[3 ]. module in mod],
860
865
typeof (f). name. mt)
861
866
end
862
867
@@ -871,7 +876,8 @@ function methods_including_ambiguous(@nospecialize(f), @nospecialize(t))
871
876
return MethodList (Method[m[3 ] for m in ms], typeof (f). name. mt)
872
877
end
873
878
874
- function methods (@nospecialize (f), mod:: Union{Module,Nothing} = nothing )
879
+ function methods (@nospecialize (f),
880
+ @nospecialize (mod:: Union{Module,AbstractArray{Module},Tuple{Vararg{Module}}} = ()))
875
881
# return all matches
876
882
return methods (f, Tuple{Vararg{Any}}, mod)
877
883
end
0 commit comments