Is there a strict version of `hasmethod`

which only gives true if there is a specialized method with precisely the types I provide in the `Tuple`

?

```
julia> f(x::Any) = "any"
f (generic function with 1 method)
julia> f(x::Int) = "int"
f (generic function with 2 methods)
julia> hasmethod(f, (Float64,))
true
julia> hasspecialization(f, (Float64,)) # does a function like this exist?
false
```

1 Like

```
julia> f(x::Any) = "any"
f (generic function with 2 methods)
julia> f(x::Int) = "int"
f (generic function with 2 methods)
julia> function hasspecialization(f, args)
m = which(f, Tuple{Float64})
return m.sig == Tuple{typeof(f), args...}
end
hasspecialization (generic function with 1 method)
julia> hasspecialization(f, (Float64,))
false
julia> f(x::Float64) = "float64"
f (generic function with 3 methods)
julia> hasspecialization(f, (Float64,))
true
```

maybe… Not very tested.

4 Likes

Good enough for my use case. Thanks.