Skip to content

Commit 1645d39

Browse files
committed
Switch to using invokelatest
1 parent 47b9c7a commit 1645d39

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

REQUIRE

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
julia 0.4
2+
Compat 0.25

src/Mocking.jl

+7-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ __precompile__(true)
22

33
module Mocking
44

5+
import Compat: invokelatest
6+
57
include("expr.jl")
68

79
export @patch, @mock, Patch, apply
@@ -182,15 +184,15 @@ macro mock(expr)
182184
args_var = gensym("args")
183185

184186
# Note: The fix to Julia issue #265 (PR #17057) introduced changes where no compiled
185-
# calls could be made to functions compiled afterwards. Since the `apply` do block
186-
# syntax compiles the do block function before evaluating the do "outer" function this
187-
# means our patch functions will be compiled after the "inner" function.
188-
# Also note that we need to QuoteNode args_var to handle Symbols in args_var.
187+
# calls could be made to functions compiled afterwards. Since the `Mocking.apply`
188+
# do-block syntax compiles the body of the do-block function before evaluating the
189+
# "outer" function this means our patch functions will be compiled after the "inner"
190+
# function.
189191
result = quote
190192
local $env_var = Mocking.get_active_env()
191193
local $args_var = tuple($(args...))
192194
if Mocking.ismocked($env_var, $func_name, $args_var)
193-
eval(Expr(:call, $env_var.mod.$func, map(QuoteNode, $args_var)...))
195+
Mocking.invokelatest($env_var.mod.$func, $args_var...)
194196
else
195197
$func($args_var...)
196198
end

0 commit comments

Comments
 (0)