Are type constraints in certain method definitions in LinearAlgebra necessary?

Eg getindex for adjoint and transpose:

@propagate_inbounds getindex(A::AdjOrTransAbsMat, i::Int, j::Int) = wrapperop(A)(A.parent[j, i])

Why do i and j need to be constrained to Ints? They may in principle be anything that the parent array supports, and the wrapper should simply switch the order. Is this necessary for ambiguity resolution? In that case, custom arrays that accept non-int indices – are they expected to add methods to getindex for Adjoint, Transpose and other such wrappers?

If you search Base and the standard libraries, it seems that about half of the getindex definitions accept Integer and the other half require Int. It’s a bit annoying…

1 Like