Skip to content

Commit

Permalink
Merge pull request #21761 from JuliaLang/jb/specificity21750
Browse files Browse the repository at this point in the history
fix method specificity issue causing problems for pr #21750
  • Loading branch information
JeffBezanson authored May 10, 2017
2 parents 9f69d24 + 37f20f1 commit d394a93
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/subtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -2320,6 +2320,8 @@ static int tuple_morespecific(jl_datatype_t *cdt, jl_datatype_t *pdt, int invari

if (ci >= clenf && !cseq) {
if (pseq && plenr <= clenr+1) return 1;
// shorter tuples are more specific, to ensure transitivity with varargs
if (!pseq && clenr < plenr) return 1;
break;
}
if (pi >= plenf && !pseq) {
Expand Down
9 changes: 9 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ _z_z_z_(::Int, c...) = 3
@test args_morespecific(Tuple{Type{Pair{A,B} where B}} where A, Tuple{DataType})
@test args_morespecific(Tuple{Union{Int,String},Type{Pair{A,B} where B}} where A, Tuple{Integer,UnionAll})

# PR #21750
let A = Tuple{Any, Tuple{Vararg{Integer,N} where N}},
B = Tuple{Any, Tuple{Any}},
C = Tuple{Any, Tuple{}}
@test args_morespecific(A, B)
@test args_morespecific(C, A)
@test args_morespecific(C, B)
end

# with bound varargs

_bound_vararg_specificity_1{T,N}(::Type{Array{T,N}}, d::Vararg{Int, N}) = 0
Expand Down

0 comments on commit d394a93

Please sign in to comment.