diff --git a/REQUIRE b/REQUIRE index 824a445..1d8bdc4 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,2 +1,2 @@ julia 0.6 -Compat 0.38 \ No newline at end of file +Compat 0.47 \ No newline at end of file diff --git a/src/Mocking.jl b/src/Mocking.jl index f9c7ba5..d20617d 100644 --- a/src/Mocking.jl +++ b/src/Mocking.jl @@ -2,17 +2,10 @@ __precompile__(true) module Mocking -import Compat: uninitialized - -# Avoid using MicroLogging for compatibility as it significantly changes the formatting. -if VERSION < v"0.7.0-DEV.2988" - for func in (:info, :warn) - @eval begin - macro $func(args...) - Expr(:call, $func, map(esc, args)...) - end - end - end +import Compat: uninitialized, @info, @warn + +if VERSION < v"0.7.0-DEV.3455" + hasmethod(f, t) = Base.method_exists(f, t) end include("expr.jl") @@ -195,7 +188,7 @@ function ismocked(pe::PatchEnv, func_name::Symbol, args::Tuple) if isdefined(pe.mod, func_name) func = Core.eval(pe.mod, func_name) types = map(arg -> isa(arg, Type) ? Type{arg} : typeof(arg), args) - exists = method_exists(func, types) + exists = hasmethod(func, types) if pe.debug @info("calling $func_name$(types)") diff --git a/src/expr.jl b/src/expr.jl index b5bd167..1011aef 100644 --- a/src/expr.jl +++ b/src/expr.jl @@ -1,9 +1,11 @@ -# Note: Needed for compatibility with the Julia 0.6 type system change: -# https://github.com/JuliaLang/julia/pull/18457 -if isdefined(Base, :unwrap_unionall) - import Base: unwrap_unionall -else - unwrap_unionall(t::Type) = t +using Base: unwrap_unionall + +if VERSION < v"0.7.0-DEV.3539" + nameof(f::Function) = Base.function_name(f) +end + +if VERSION < v"0.7.0-DEV.3460" + parentmodule(f, t) = Base.function_module(f, t) end @@ -32,10 +34,10 @@ function binding_expr(t::Type) end function binding_expr(f::Function) if isa(f, Core.Builtin) - return Base.function_name(f) + return nameof(f) end - m = Base.function_module(f, Tuple) - joinbinding(fullname(m)..., Base.function_name(f)) + m = parentmodule(f, Tuple) + joinbinding(fullname(m)..., nameof(f)) end