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
```

This isn’t anything specific to `Type`

or `Tuple`

. `NTuple{2,Int}`

is a subtype of but isn’t `NTuple{2,Any}`

which means that `Type{NTuple{2,Int}}`

is not a subtype of `Type{NTuple{2,Any}}`

in the same way as `Type{Int}`

not being a subtype of `Type{Any}`

or `Vector{Int}`

not being a subtype of `Vector{Any}`

.

Thank you. The following does work on 0.5 though:

```
julia> g{N}(x::Type{NTuple{N}}) = x
g (generic function with 1 method)
julia> g(Tuple{Int,Float64})
Tuple{Int64,Float64}
```

So I thought that replacing `NTuple{N}`

with `NTuple{N, Any}`

would work on 0.6.

The v0.5 type-system was very buggy when it came to tuples. Now it can compute with the correctly, which also forces usage of the correct formulation for describing the set:

```
g{T <: NTuple{N, Any}}(x::Type{T}) = x
```

2 Likes