Skip to content

Commit 9ab7f87

Browse files
authored
Handle type methodtables properly (#5)
For types, the .mt field is for Type; .ms is the constructor method list
1 parent ef96bc5 commit 9ab7f87

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/visit.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ function _visit(@nospecialize(operation), @nospecialize(f::Callable), visited::I
9393
if operation(f)
9494
ml = methods(f)
9595
_visit(operation, ml.mt, visited, print)
96-
Base.visit(ml.mt) do m
96+
for m in ml.ms
9797
_visit(operation, m, visited, print)
9898
end
9999
end

test/runtests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ end
5858
true
5959
end
6060
@test nitems[] == 0
61+
62+
# Handle constructors properly
63+
visit(IndexStyle) do m
64+
isa(m, Method) && @test Base.unwrap_unionall(m.sig).parameters[1].parameters[1] === IndexStyle
65+
return m === IndexStyle
66+
end
6167
end
6268

6369
@testset "Backedges" begin

0 commit comments

Comments
 (0)