Determine whether any one-argument method exists

It’s not a bug. hasmethod(f, Tuple{Union{}}) or hasmethod(f, Tuple{Any}) are asking whether f has a method whose argument type is Any or any supertype of Any, not any subtype which is what you are hoping for.

For example, hasmethod(f, Tuple{Real}) will succeed if there is an f(x::Real) method, but also if there is an f(x::Number) or f(x::Any) method. It won’t succeed if there is only an f(x::Int) method.

One thing you could do to check whether f has a single-argument method would be to check any(m -> m.nargs == 2, methods(f)), although this relies on the undocumented internal field nargs of the Method type. (m.nargs == 2 seems to be correct for to test for 1 argument, since the function itself is apparently counted as an “argument” here.)

Update: My bad, I was confusing Union{} with Any. As was pointed out below, Union{} is a supertype of every type, so it seems like it should work.