@@ -866,14 +866,19 @@ Return the method table for `f`.
866
866
867
867
If `types` is specified, return an array of methods whose types match.
868
868
If `module` is specified, return an array of methods defined in this module.
869
+ A list of modules can also be specified as an array or tuple.
869
870
"""
870
- function methods (@nospecialize (f), @nospecialize (t), mod:: Union{Module,Nothing} = nothing )
871
+ function methods (@nospecialize (f), @nospecialize (t),
872
+ @nospecialize (mod:: Union{Module,AbstractArray{Module},Tuple{Vararg{Module}}} = ()))
873
+ if mod isa Module
874
+ mod = (mod,)
875
+ end
871
876
if isa (f, Core. Builtin)
872
877
throw (ArgumentError (" argument is not a generic function" ))
873
878
end
874
879
t = to_tuple_type (t)
875
880
world = typemax (UInt)
876
- MethodList (Method[m[3 ] for m in _methods (f, t, - 1 , world) if mod === nothing || m[3 ]. module == mod],
881
+ MethodList (Method[m[3 ] for m in _methods (f, t, - 1 , world) if isempty ( mod) || m[3 ]. module in mod],
877
882
typeof (f). name. mt)
878
883
end
879
884
@@ -888,7 +893,8 @@ function methods_including_ambiguous(@nospecialize(f), @nospecialize(t))
888
893
return MethodList (Method[m[3 ] for m in ms], typeof (f). name. mt)
889
894
end
890
895
891
- function methods (@nospecialize (f), mod:: Union{Module,Nothing} = nothing )
896
+ function methods (@nospecialize (f),
897
+ @nospecialize (mod:: Union{Module,AbstractArray{Module},Tuple{Vararg{Module}}} = ()))
892
898
# return all matches
893
899
return methods (f, Tuple{Vararg{Any}}, mod)
894
900
end
0 commit comments