diff --git a/stdlib/InteractiveUtils/src/InteractiveUtils.jl b/stdlib/InteractiveUtils/src/InteractiveUtils.jl index 459cad76e7d60..6f8ba9ea0b080 100644 --- a/stdlib/InteractiveUtils/src/InteractiveUtils.jl +++ b/stdlib/InteractiveUtils/src/InteractiveUtils.jl @@ -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) @@ -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 diff --git a/stdlib/InteractiveUtils/test/runtests.jl b/stdlib/InteractiveUtils/test/runtests.jl index bf32ea0eb6159..5b6adbbb24d8d 100644 --- a/stdlib/InteractiveUtils/test/runtests.jl +++ b/stdlib/InteractiveUtils/test/runtests.jl @@ -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