From 30bb198657a81c8d198bd346520ac9f3672539f4 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Thu, 13 Oct 2016 20:26:18 -0400 Subject: [PATCH] fix specificity of sigs that are strict subtypes of vararg sigs --- src/jltypes.c | 4 +++- test/core.jl | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/jltypes.c b/src/jltypes.c index b16089280dc8a..d5db6e08aec83 100644 --- a/src/jltypes.c +++ b/src/jltypes.c @@ -3132,7 +3132,9 @@ int jl_args_morespecific_fix1(jl_value_t *a, jl_value_t *b, int swap) if (changed) { JL_GC_PUSH1(&newtta); int ret; - if (swap) + if (type_eqv_(b, newtta)) + ret = swap; + else if (swap) ret = jl_args_morespecific_(b, (jl_value_t*)newtta); else ret = jl_args_morespecific_((jl_value_t*)newtta, b); diff --git a/test/core.jl b/test/core.jl index 6b4d326af6d9b..4ab6c3786bb82 100644 --- a/test/core.jl +++ b/test/core.jl @@ -219,6 +219,11 @@ end # with bound varargs +_bound_vararg_specificity_1{T,N}(::Type{Array{T,N}}, d::Vararg{Int, N}) = 0 +_bound_vararg_specificity_1{T}(::Type{Array{T,1}}, d::Int) = 1 +@test _bound_vararg_specificity_1(Array{Int,1}, 1) == 1 +@test _bound_vararg_specificity_1(Array{Int,2}, 1, 1) == 0 + # issue #11840 typealias TT11840{T} Tuple{T,T} f11840(::Type) = "Type"