Skip to content

Commit 6c24103

Browse files
authored
Add test for issue #48802 (#48984)
Was fixed by #48954
1 parent 9f997fc commit 6c24103

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/reflection.jl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,31 @@ Base.delete_method(m)
726726
@test faz4(1) == 1
727727
@test faz4(1.0) == 1
728728

729+
# Deletion & invoke (issue #48802)
730+
function f48802!(log, x::Integer)
731+
log[] = "default"
732+
return x + 1
733+
end
734+
function addmethod_48802()
735+
@eval function f48802!(log, x::Int)
736+
ret = invoke(f48802!, Tuple{Any, Integer}, log, x)
737+
log[] = "specialized"
738+
return ret
739+
end
740+
end
741+
log = Ref{String}()
742+
@test f48802!(log, 1) == 2
743+
@test log[] == "default"
744+
addmethod_48802()
745+
@test f48802!(log, 1) == 2
746+
@test log[] == "specialized"
747+
Base.delete_method(which(f48802!, Tuple{Any, Int}))
748+
@test f48802!(log, 1) == 2
749+
@test log[] == "default"
750+
addmethod_48802()
751+
@test f48802!(log, 1) == 2
752+
@test log[] == "specialized"
753+
729754
# Methods with keyword arguments
730755
fookw(x; direction=:up) = direction
731756
fookw(y::Int) = 2

0 commit comments

Comments
 (0)