From e375fe2cb6330a0e135c97450f0c98c424bf3f93 Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Sun, 12 Mar 2023 05:43:52 -0500 Subject: [PATCH] Add test for issue #48802 Was fixed by #48954 --- test/reflection.jl | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test/reflection.jl b/test/reflection.jl index 0c1081ba2c42f..7fa73d56df2b2 100644 --- a/test/reflection.jl +++ b/test/reflection.jl @@ -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