Skip to content

Commit

Permalink
Fix methodswith consistency (#41016)
Browse files Browse the repository at this point in the history
Fixes #41010
  • Loading branch information
endremborza authored May 31, 2021
1 parent 46bc859 commit b3bb9ce
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions stdlib/InteractiveUtils/src/InteractiveUtils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ The optional second argument restricts the search to a particular module or func
If keyword `supertypes` is `true`, also return arguments with a parent type of `typ`,
excluding type `Any`.
"""
function methodswith(t::Type, f::Function, meths = Method[]; supertypes::Bool=false)
function methodswith(t::Type, f::Base.Callable, meths = Method[]; supertypes::Bool=false)
for d in methods(f)
if any(function (x)
let x = rewrap_unionall(x, d.sig)
Expand All @@ -189,7 +189,7 @@ function _methodswith(t::Type, m::Module, supertypes::Bool)
for nm in names(m)
if isdefined(m, nm)
f = getfield(m, nm)
if isa(f, Function)
if isa(f, Base.Callable)
methodswith(t, f, meths; supertypes = supertypes)
end
end
Expand Down
12 changes: 12 additions & 0 deletions stdlib/InteractiveUtils/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -568,3 +568,15 @@ file, ln = functionloc(versioninfo, Tuple{})
code_native(io, eltype, Tuple{Int})
@test occursin("eltype", String(take!(io)))
end

@testset "Issue #41010" begin
struct A41010 end

struct B41010
a::A41010
end
export B41010

ms = methodswith(A41010, @__MODULE__) |> collect
@test ms[1].name == :B41010
end

0 comments on commit b3bb9ce

Please sign in to comment.