Macros work at the level of expressions and should not be messing with their meaning, e.g., care which types or values an expression represents. They can generate an expression containing an appropriate condition though:
macro my_macro(func_expr)
func = JLFunction(func_expr)
type_annotation_expr = func.args[1].args[2]
quote
if $(esc(type_annotation_expr)) <: Array
print("Got a subtype!")
# Insert expansion suitable for subtypes here ...
else
# Insert alternative expansion here ...
nothing
end
end
end
julia> @my_macro function f(x::Vector{Int}) end
Got a subtype!
julia> @my_macro function g(x::Real) end