Skip to content

Commit 56b68d9

Browse files
JeffBezansontkelman
authored andcommitted
fix #22164 and #22002, method sorting problems
fix #22164, specificity issue in ForwardDiff (cherry picked from commit e92eb58) partial backport of #22162
1 parent 68e911b commit 56b68d9

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/subtype.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2600,10 +2600,9 @@ static int type_morespecific_(jl_value_t *a, jl_value_t *b, int invariant, jl_ty
26002600
if (!jl_is_type(b))
26012601
return 0;
26022602
if (invariant) {
2603-
if (num_occurs((jl_tvar_t*)a, env) < 2)
2604-
return 0;
26052603
if (eq_msp(((jl_tvar_t*)a)->ub, b, env))
2606-
return 1;
2604+
return num_occurs((jl_tvar_t*)a, env) >= 2;
2605+
return 0;
26072606
}
26082607
return type_morespecific_((jl_value_t*)((jl_tvar_t*)a)->ub, b, 0, env);
26092608
}

test/core.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,15 @@ _bound_vararg_specificity_1{T}(::Type{Array{T,1}}, d::Int) = 1
9898
@test args_morespecific(Tuple{Array}, Tuple{AbstractVector})
9999
@test args_morespecific(Tuple{Matrix}, Tuple{AbstractVector})
100100

101+
# issue #22164 and #22002
102+
let A = Tuple{Type{D},D} where D<:Pair,
103+
B = Tuple{Type{Any}, Any},
104+
C = Tuple{Type{Pair}, Pair}
105+
@test args_morespecific(C, A)
106+
@test !args_morespecific(A, B)
107+
@test !args_morespecific(C, B)
108+
end
109+
101110
# issue #12939
102111
module Issue12939
103112
abstract type Abs; end

0 commit comments

Comments
 (0)