Skip to content

Commit 28e3361

Browse files
committed
Update to julia#58131
1 parent 4d2f3f5 commit 28e3361

File tree

1 file changed

+2
-27
lines changed

1 file changed

+2
-27
lines changed

src/visit.jl

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,11 @@
11
function methods_with(@nospecialize(T::Type), world::UInt = Base.get_world_counter())
22
meths = Set{Method}()
3-
visited = Set{Module}()
4-
for mod in Base.loaded_modules_array()
5-
methods_with!(meths, T, world, mod, visited)
6-
end
7-
# Also handle the methods defined for Type
8-
mt = methods(Type).mt
93
T = Base.unwrap_unionall(T)
104
Tname = T.name
11-
for method in Base.MethodList(mt)
12-
method.module === Tname.module && method.name === Tname.name && continue # skip constructor
13-
hastype(method.sig, T) && push!(meths, method)
14-
end
15-
return meths
16-
end
17-
18-
function methods_with!(meths, @nospecialize(T::Type), world, mod::Module, visited::Set{Module})
19-
mod in visited && return
20-
push!(visited, mod)
21-
# Traverse submodules
22-
for name in names(mod; all=true, imported=false)
23-
isdefined(mod, name) || continue
24-
obj = getglobal(mod, name)
25-
if isa(obj, Module)
26-
methods_with!(meths, T, world, obj, visited)
27-
end
28-
end
29-
Base.foreach_module_mtable(mod, world) do mt::Core.MethodTable
30-
for method in Base.MethodList(mt)
5+
Base.visit(Core.GlobalMethods) do method
6+
if method.module !== Tname.module || method.name !== Tname.name # skip constructor
317
hastype(method.sig, T) && push!(meths, method)
328
end
33-
return true
349
end
3510
return meths
3611
end

0 commit comments

Comments
 (0)