Skip to content

method_exists not working with TypeVar-parameterized types  #9043

Closed
@mauro3

Description

@mauro3

Using TypeVars 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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions