From 4dc0d5209527f8f4bc6e57efa6f89b478fc03bc5 Mon Sep 17 00:00:00 2001 From: chengchingwen Date: Sat, 11 Jan 2025 15:19:17 +0800 Subject: [PATCH 1/4] fix for julia v1.12 edge format changes --- src/Tricks.jl | 6 +++++- test/runtests.jl | 26 ++++++++++++++++++-------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/Tricks.jl b/src/Tricks.jl index 0cd8749..6a4f919 100644 --- a/src/Tricks.jl +++ b/src/Tricks.jl @@ -100,7 +100,11 @@ function _method_table_all_edges_all_methods(f, T, world = Base.get_world_counte # We add an edge to the MethodTable itself so that when any new methods # are defined, it recompiles the function. - mt_edges = Core.Compiler.vect(mt, Tuple{f,Vararg{Any}}) + @static if VERSION < v"1.12.0-DEV" + mt_edges = Core.Compiler.vect(mt, Tuple{f,Vararg{Any}}) + else + mt_edges = Core.Compiler.vect(Tuple{f, Vararg{Any}}, mt) + end # We want to add an edge to _every existing method instance_, so that # the deletion of any one of them will trigger recompilation of the function. diff --git a/test/runtests.jl b/test/runtests.jl index 3b1e384..891b219 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -125,7 +125,7 @@ end @test static_method_count(j) == 2 @test (length ∘ collect ∘ static_methods)(j, Tuple{Int}) == 1 - @test static_method_count(j, Tuple{Int,Int}) == 1 + @test static_method_count(j, Tuple{Int}) == 1 @test (length ∘ collect ∘ static_methods)(j, Tuple{Int,Int}) == 1 @test static_method_count(j, Tuple{Int,Int}) == 1 @test (length ∘ collect ∘ static_methods)(j, Tuple{Int,Int,Int}) == 1 @@ -156,13 +156,23 @@ end @testset "delete method" begin - while length(collect(methods(j))) > 0 - Base.delete_method((first ∘ methods)(j)) - - T = Tuple{Any, Vararg{Any}} - @test (length ∘ collect ∘ static_methods)(j, T) == length(collect(methods(j))) - @test static_method_count(j, T) == length(collect(methods(j))) - end + # while length(collect(methods(j))) > 0 + # Base.delete_method((first ∘ methods)(j)) + + # T = Tuple{Any, Vararg{Any}} + # @test (length ∘ collect ∘ static_methods)(j, T) == length(collect(methods(j))) + # @test static_method_count(j, T) == length(collect(methods(j))) + # end + # Base.delete_method does not trigger recompilation in the loop + @label deletion_loop + length(collect(methods(j))) > 0 || @goto deletion_loop_end + Base.delete_method((first ∘ methods)(j)) + + T = Tuple{Any, Vararg{Any}} + @test (length ∘ collect ∘ static_methods)(j, T) == length(collect(methods(j))) + @test static_method_count(j, T) == length(collect(methods(j))) + @goto deletion_loop + @label deletion_loop_end end end From 03302c593d078967e3a636ec1c249c2a58f25aae Mon Sep 17 00:00:00 2001 From: chengchingwen Date: Sat, 11 Jan 2025 19:37:31 +0800 Subject: [PATCH 2/4] better VERSION for branching --- src/Tricks.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tricks.jl b/src/Tricks.jl index 6a4f919..c8c8de3 100644 --- a/src/Tricks.jl +++ b/src/Tricks.jl @@ -100,7 +100,7 @@ function _method_table_all_edges_all_methods(f, T, world = Base.get_world_counte # We add an edge to the MethodTable itself so that when any new methods # are defined, it recompiles the function. - @static if VERSION < v"1.12.0-DEV" + @static if VERSION < v"1.12.0-DEV.1531" mt_edges = Core.Compiler.vect(mt, Tuple{f,Vararg{Any}}) else mt_edges = Core.Compiler.vect(Tuple{f, Vararg{Any}}, mt) From 7627c31d346da6b93990c6967229bdef80cf6a1a Mon Sep 17 00:00:00 2001 From: chengchingwen Date: Sun, 12 Jan 2025 19:09:05 +0800 Subject: [PATCH 3/4] insert latestworld --- test/runtests.jl | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index 891b219..f9e2d27 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -156,23 +156,13 @@ end @testset "delete method" begin - # while length(collect(methods(j))) > 0 - # Base.delete_method((first ∘ methods)(j)) - - # T = Tuple{Any, Vararg{Any}} - # @test (length ∘ collect ∘ static_methods)(j, T) == length(collect(methods(j))) - # @test static_method_count(j, T) == length(collect(methods(j))) - # end - # Base.delete_method does not trigger recompilation in the loop - @label deletion_loop - length(collect(methods(j))) > 0 || @goto deletion_loop_end - Base.delete_method((first ∘ methods)(j)) - - T = Tuple{Any, Vararg{Any}} - @test (length ∘ collect ∘ static_methods)(j, T) == length(collect(methods(j))) - @test static_method_count(j, T) == length(collect(methods(j))) - @goto deletion_loop - @label deletion_loop_end + while length(collect(methods(j))) > 0 + Base.delete_method((first ∘ methods)(j)) + @static isdefined(Core, Symbol("@latestworld")) && Core.@latestworld + T = Tuple{Any, Vararg{Any}} + @test (length ∘ collect ∘ static_methods)(j, T) == length(collect(methods(j))) + @test static_method_count(j, T) == length(collect(methods(j))) + end end end From a513a2e8e10bd4aaca64936b2a7e997ae22bc7d8 Mon Sep 17 00:00:00 2001 From: chengchingwen Date: Sun, 12 Jan 2025 19:48:35 +0800 Subject: [PATCH 4/4] bump version --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 96d1858..5b1b1b3 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Tricks" uuid = "410a4b4d-49e4-4fbc-ab6d-cb71b17b3775" authors = ["Frames White"] -version = "0.1.9" +version = "0.1.10" [compat] julia = "1.0"