In this particular case, I needed this in order to check to see if there was an extant method implementation for a specific argument type in a typechecker, in a kind of ghetto re-implementation of `ml_matches`

with nonzero `lim`

, as a result of wanting to precisely identify methods potentially invoked by a call (`methods`

conservatively over-approximates the set, in the case where all subtypes of a type have implementations) and check to make sure that implementations exist for every subtype. Since I’d rather implement as much of my algorithm in Julia as possible, I would at this point rather avoid calling `ml_matches`

.

The problem that required this arises when filtering the list of potentially invoked methods by type. My algorithm works by subsetting the list of methods to those in a typing relation to the current “objective” type, then recursing on the subtypes of the objective until it either runs out of methods (a failure, in which case a more general implementation must exist/be used), or run out of subtypes (a success). This runs into trouble, however, in the case of something like trying to find an implementation of `size`

on an `AbstractSparseArray{Int64,Ti,1} where Ti`

, whose sole subtype (in a fresh 0.6.0 REPL) is `SparseVector{Int64,Ti} where Ti<:Integer`

. However, only one implementation of `size`

is available, taking a `SparseVector{T,V} where T where V`

, which is not a subtype or supertype of `AbstractSparseArray{Int64,Ti,1}`

, which is removed. Then, the next step of the algorithm tries to find a method for `SparseVector{Int64, Ti} where Ti <: Integer`

. However, since the implementation for `SparseVector{T,V} where T where V`

was filtered out at the previous iteration, this fails.

The fix is that instead of filtering on subtypes of `AbstractSparseArray{Int64,Ti,1}`

, the list of functions is filtered based on subtypes of `AbstractSparseArray{T,U,V} where T where U where V`

, of which `SparseArray{T,U} where T where U`

is a subtype. This works perfectly for my limited use case. At some point I’ll rip this out and replace it with a C call to `ml_matches`

with the appropriate limited mode turned on and some patches to require exhaustiveness, but I wanted to see if I could write it all in Julia.