diff --git a/src/sampling.jl b/src/sampling.jl index c0c40e8..c20f0ed 100644 --- a/src/sampling.jl +++ b/src/sampling.jl @@ -574,12 +574,10 @@ pair_to_make((a, b)::Pair) = pair_to_make(x) = x -@inline Sampler(RNG::Type{<:AbstractRNG}, p::Pair{<:Union{DataType,UnionAll}}, - r::Repetition) = - Sampler(RNG, pair_to_make(p), r) +@inline Sampler(RNG::Type{<:AbstractRNG}, p::Pair, r::Repetition) = + Sampler(RNG, pair_to_make(p), r) # nothing can be inferred when only the pair type is available -@inline gentype(::Type{<:Pair{<:Union{DataType,UnionAll}}}) = Any +@inline gentype(::Type{<:Pair}) = Any -@inline gentype(p::Pair{<:Union{DataType,UnionAll}}) = - gentype(pair_to_make(p)) +@inline gentype(p::Pair) = gentype(pair_to_make(p)) diff --git a/test/runtests.jl b/test/runtests.jl index fcf3900..4912be8 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -570,7 +570,7 @@ end @testset "rand(T => x) & rand(T => (x, y, ...))" begin @test rand(Complex => Int) isa Complex{Int} @test rand(Pair => (String, Int8)) isa Pair{String,Int8} - @test_throws ArgumentError rand(1=>2) # should not call rand(make(1, 2)) + @test_throws MethodError rand(1=>2) # calls rand(make(1, 2)) @test rand(Complex => Int, 3) isa Vector{Complex{Int}} @test rand(Pair => (String, Int8), Set, 3) isa Set{Pair{String,Int8}}