Skip to content

Commit

Permalink
Add test for issue JuliaLang#48802 (JuliaLang#48984)
Browse files Browse the repository at this point in the history
Was fixed by JuliaLang#48954
  • Loading branch information
timholy authored and Xnartharax committed Apr 13, 2023
1 parent e4d9263 commit d023f04
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,31 @@ Base.delete_method(m)
@test faz4(1) == 1
@test faz4(1.0) == 1

# Deletion & invoke (issue #48802)
function f48802!(log, x::Integer)
log[] = "default"
return x + 1
end
function addmethod_48802()
@eval function f48802!(log, x::Int)
ret = invoke(f48802!, Tuple{Any, Integer}, log, x)
log[] = "specialized"
return ret
end
end
log = Ref{String}()
@test f48802!(log, 1) == 2
@test log[] == "default"
addmethod_48802()
@test f48802!(log, 1) == 2
@test log[] == "specialized"
Base.delete_method(which(f48802!, Tuple{Any, Int}))
@test f48802!(log, 1) == 2
@test log[] == "default"
addmethod_48802()
@test f48802!(log, 1) == 2
@test log[] == "specialized"

# Methods with keyword arguments
fookw(x; direction=:up) = direction
fookw(y::Int) = 2
Expand Down

0 comments on commit d023f04

Please sign in to comment.