Skip to content

methods returns wrong result for triangular dispatch #18348

Closed
@yuyichao

Description

See below, methods returns two methods even though only the second one (the first in the returned array) can possibly be called. This is the reason we are doing a dynamic dispatch at all in #18331 . (and without this fixed allocation elimination can't fully work either)

julia> f{T<:Any}(::Type{T}, x) = 1
f (generic function with 1 method)

julia> f{T<:Any}(::Type{T}, x::T) = 2
f (generic function with 2 methods)

julia> methods(f, Tuple{Type{Any},Any})
#2 methods for generic function "f":
f{T}(::Type{T}, x::T) at REPL[2]:1
f{T}(::Type{T}, x) at REPL[1]:1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    types and dispatchTypes, subtyping and method dispatch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions