Consider the following:
julia> f{N}(x::Type{NTuple{N,Int}}) = x
f (generic function with 1 method)
julia> g{N}(x::Type{NTuple{N,Any}}) = x
g (generic function with 1 method)
julia> f(Tuple{Int,Int})
Tuple{Int64,Int64}
julia> g(Tuple{Int,Int})
ERROR: MethodError: no method matching g(::Type{Tuple{Int64,Int64}})
Closest candidates are:
g{N}(::Type{Tuple{Vararg{Any,N}}}) at REPL[2]:1
I would have expected g
to be called. Is it because of some covariance thing with Type
?
This works:
h(x::Type{T}) where T <: NTuple{N,Any} where N = x