From a00b0ff19cf07b125c7d3ddac311af1d60e3394f Mon Sep 17 00:00:00 2001 From: KristofferC Date: Mon, 21 Feb 2022 09:48:28 +0100 Subject: [PATCH] make string definition work on call overloadable structs --- src/utils.jl | 1 + test/runtests.jl | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/src/utils.jl b/src/utils.jl index 47eb245..45cc8ac 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -5,6 +5,7 @@ function checkname(fdef::Expr, name) (fdef.head === :where || fdef.head == :(::)) && return checkname(fproto, name) fdef.head === :call || return false if fproto isa Expr + fproto.head == :(::) && return fproto.args[2] == name # A metaprogramming-generated function fproto.head === :$ && return true # uncheckable, let's assume all is well # Is the check below redundant? diff --git a/test/runtests.jl b/test/runtests.jl index dd92b68..cad30c8 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -252,3 +252,12 @@ end body, _ = CodeTracking.definition(String, @which Foo.Bar.fit(1, 2)) @test body == "Foo.Bar.fit(a, b) = a + b" end + +struct CallOverload + z +end +(f::CallOverload)(arg) = f.z + arg +@testset "call syntax" begin + body, _ = CodeTracking.definition(String, @which CallOverload(1)(1)) + @test body == "(f::CallOverload)(arg) = f.z + arg" +end