Skip to content

Commit f03279d

Browse files
JeffBezansonKristofferC
authored andcommitted
fix #34286, regression in methods with empty tuple of types (#34291)
(cherry picked from commit 8dc0d93)
1 parent 0835ee0 commit f03279d

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

base/reflection.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -868,14 +868,14 @@ end
868868
Return the method table for `f`.
869869
870870
If `types` is specified, return an array of methods whose types match.
871-
If `module` is specified, return an array of methods defined in this module.
872-
A list of modules can also be specified as an array or tuple.
871+
If `module` is specified, return an array of methods defined in that module.
872+
A list of modules can also be specified as an array.
873873
874874
!!! compat "Julia 1.4"
875875
At least Julia 1.4 is required for specifying a module.
876876
"""
877877
function methods(@nospecialize(f), @nospecialize(t),
878-
@nospecialize(mod::Union{Module,AbstractArray{Module},Tuple{Vararg{Module}},Nothing}=nothing))
878+
@nospecialize(mod::Union{Module,AbstractArray{Module},Nothing}=nothing))
879879
if mod isa Module
880880
mod = (mod,)
881881
end
@@ -900,7 +900,7 @@ function methods_including_ambiguous(@nospecialize(f), @nospecialize(t))
900900
end
901901

902902
function methods(@nospecialize(f),
903-
@nospecialize(mod::Union{Module,AbstractArray{Module},Tuple{Vararg{Module}},Nothing}=nothing))
903+
@nospecialize(mod::Union{Module,AbstractArray{Module},Nothing}=nothing))
904904
# return all matches
905905
return methods(f, Tuple{Vararg{Any}}, mod)
906906
end

test/reflection.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,7 @@ end
897897
module TestMod33403
898898
f(x) = 1
899899
f(x::Int) = 2
900+
g() = 3
900901

901902
module Sub
902903
import ..TestMod33403: f
@@ -905,18 +906,19 @@ end
905906
end
906907

907908
@testset "methods with module" begin
908-
using .TestMod33403: f
909+
using .TestMod33403: f, g
909910
@test length(methods(f)) == 3
910911
@test length(methods(f, (Int,))) == 1
911912

912913
@test length(methods(f, TestMod33403)) == 2
913-
@test length(methods(f, (TestMod33403,))) == 2
914914
@test length(methods(f, [TestMod33403])) == 2
915915
@test length(methods(f, (Int,), TestMod33403)) == 1
916-
@test length(methods(f, (Int,), (TestMod33403,))) == 1
916+
@test length(methods(f, (Int,), [TestMod33403])) == 1
917917

918918
@test length(methods(f, TestMod33403.Sub)) == 1
919-
@test length(methods(f, (TestMod33403.Sub,))) == 1
919+
@test length(methods(f, [TestMod33403.Sub])) == 1
920920
@test length(methods(f, (Char,), TestMod33403.Sub)) == 1
921921
@test length(methods(f, (Int,), TestMod33403.Sub)) == 0
922+
923+
@test length(methods(g, ())) == 1
922924
end

0 commit comments

Comments
 (0)