Skip to content

Commit 8e519c5

Browse files
authored
make string definition work on call overloadable structs (#89)
1 parent c309a9c commit 8e519c5

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/utils.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ function checkname(fdef::Expr, name)
55
(fdef.head === :where || fdef.head == :(::)) && return checkname(fproto, name)
66
fdef.head === :call || return false
77
if fproto isa Expr
8+
fproto.head == :(::) && return fproto.args[2] == name
89
# A metaprogramming-generated function
910
fproto.head === :$ && return true # uncheckable, let's assume all is well
1011
# Is the check below redundant?

test/runtests.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,3 +252,12 @@ end
252252
body, _ = CodeTracking.definition(String, @which Foo.Bar.fit(1, 2))
253253
@test body == "Foo.Bar.fit(a, b) = a + b"
254254
end
255+
256+
struct CallOverload
257+
z
258+
end
259+
(f::CallOverload)(arg) = f.z + arg
260+
@testset "call syntax" begin
261+
body, _ = CodeTracking.definition(String, @which CallOverload(1)(1))
262+
@test body == "(f::CallOverload)(arg) = f.z + arg"
263+
end

0 commit comments

Comments
 (0)