Skip to content

Commit 5315505

Browse files
authored
Merge pull request #217 from ChrisRackauckas-Claude/fix-julia-1.12-methodlist-compat
Fix Julia 1.12 compatibility for MethodList API change
2 parents ac4492a + 6990d34 commit 5315505

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/utils.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,11 @@ function makeif(clauses, els = nothing)
608608
end
609609

610610
unresolve1(x) = x
611-
unresolve1(f::Function) = methods(f).mt.name
611+
@static if VERSION >= v"1.12-"
612+
unresolve1(f::Function) = nameof(f)
613+
else
614+
unresolve1(f::Function) = methods(f).mt.name
615+
end
612616

613617
unresolve(ex) = prewalk(unresolve1, ex)
614618

test/utils.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ end
6363
@test flatten(quote begin; begin; f(); g(); end; begin; h(); end; f(); end; end) |> striplines == quote f(); g(); h(); f() end |> striplines
6464
end
6565

66+
@testset "prettify" begin
67+
# Test that prettify resolves function references to their names
68+
@test MacroTools.prettify(:($sin(2))) == :(sin(2))
69+
@test MacroTools.prettify(:($cos(x))) == :(cos(x))
70+
end
71+
6672
@testset "flatten try" begin # see julia#50710 and MacroTools#194 # only tests that do not include `else` -- for the full set of tests see flatten_try.jl
6773
exs = [
6874
quote try; f(); catch; end; end,

0 commit comments

Comments
 (0)