Skip to content

methods and methodswith asymmetry #41010

@endremborza

Description

@endremborza

Hello!

I opened a thread on discourse and I was advised to open an issue as well, as it is really difficult to explain behavior:

struct A end

struct B
    a::A
end

println("finds constructor with A param:")
B |> methods |> println
println("does not find constructor with A:")
A |> methodswith |> println

outputs

finds constructor with A param:
# 2 methods for type constructor:
[1] B(a::A) in Main at In[1]:4
[2] B(a) in Main at In[1]:4
does not find constructor with A:
Method[]

this was run on 1.5 but it is clearly present on master as it was pointed out to me to be the result of this line

because isa(B, Function) == false as B is a DataType

but technically there is a method with A, so I would classify this as a bug:

bm = methods(B) |> collect |> (x -> x[1])
println(bm |> typeof)
println(bm.sig)

outputs

Method
Tuple{Type{B},A}

I think I'll attempt a PR but I haven't contributed to Julia yet so it will not be straightforward

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