diff --git a/src/MatchImpl.jl b/src/MatchImpl.jl index cb115b5..b98520e 100644 --- a/src/MatchImpl.jl +++ b/src/MatchImpl.jl @@ -1,6 +1,6 @@ module MatchImpl export is_enum, - pattern_uncall, pattern_unref, @switch, @match, Where, gen_match, gen_switch + pattern_uncall, pattern_unref, pattern_unmacrocall, @switch, @match, Where, gen_match, gen_switch export Q import MLStyle using MLStyle: mlstyle_report_deprecation_msg! @@ -15,6 +15,12 @@ OptionalLn = Union{LineNumberNode, Nothing} is_enum(_)::Bool = false function pattern_uncall end function pattern_unref end +function pattern_unmacrocall(macro_func, self::Function, args::AbstractArray) + @sswitch args begin + @case [ln, m::Module, args...] + return self(macro_func(ln, m, args...)) + end +end struct Where value::Any @@ -254,7 +260,7 @@ function ex2tf(m::Module, ex::Expr) @case Expr(:macrocall, [macro_expr, ln::LineNumberNode, args...]) macro_func = m.eval(macro_expr) - return pattern_uncall(macro_func, rec, [], [], Any[ln, m, args...]) + return pattern_unmacrocall(macro_func, rec, Any[ln, m, args...]) @case a error("unknown pattern syntax $(repr(a))") diff --git a/src/Pervasives.jl b/src/Pervasives.jl index 6fbf69f..ecf7faf 100644 --- a/src/Pervasives.jl +++ b/src/Pervasives.jl @@ -188,24 +188,9 @@ function MLStyle.pattern_uncall( MLStyle.pattern_unref(Many, self, args) end -function MLStyle.pattern_uncall( - ::typeof(@eval $(Symbol("@", "raw_str"))), - self::Function, - _::AbstractArray, - _::AbstractArray, - args::AbstractArray, -) - @switch args begin - @case [ln, m, s::String] - end - self(s) -end - -function MLStyle.pattern_uncall( +function MLStyle.pattern_unmacrocall( r_str::typeof(@eval $(Symbol("@", "r_str"))), self::Function, - _::AbstractArray, - _::AbstractArray, args::AbstractArray, ) @switch args begin