Closed
Description
Using TypeVar
s for non-parameterized types works with method_exists
:
julia> I = TypeVar(:X, Integer)
X<:Integer
julia> Ii = TypeVar(:X, Int)
X<:Int64
julia> g{I<:Integer}(x::I) = x
g (generic function with 1 method)
julia> method_exists(g, (Integer,))
false
julia> method_exists(g, (Int,))
true
julia> method_exists(g, (I,))
false
julia> method_exists(g, (Ii,))
true
(Edit: Actually, shouldn't the second last return true
as the method does exist for all <:Integer
?)
But not for parameterized types:
julia> f{I<:Integer}(x::Array{I,1}) = x[5]
f (generic function with 1 method)
julia> method_exists(f, (Vector{Integer},))
true
julia> method_exists(f, (Vector{Int},))
true
julia> method_exists(f, (Vector{I},))
false
julia> method_exists(f, (Vector{Ii},))
false
I would have thought the latter two should return true
.
Metadata
Metadata
Assignees
Labels
No labels