Skip to content

Commit 2c5076b

Browse files
committed
ml-matches: ensure all methods are included
Some methods were filtered out based simply on visit order, which was not intentional, with the lim==-1 weak-edges mode. Fix #55231
1 parent f2f188d commit 2c5076b

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/gf.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3669,7 +3669,7 @@ static int sort_mlmatches(jl_array_t *t, size_t idx, arraylist_t *visited, array
36693669
int msp2 = !msp && jl_method_morespecific(m2, m);
36703670
if (!msp) {
36713671
if (subt || !include_ambiguous || (lim != -1 && msp2)) {
3672-
if (subt2 || jl_subtype((jl_value_t*)ti, m2->sig)) {
3672+
if (subt2 || ((lim != -1 || (!include_ambiguous && !msp2)) && jl_subtype((jl_value_t*)ti, m2->sig))) {
36733673
// this may be filtered out as fully intersected, if applicable later
36743674
mayexclude = 1;
36753675
}

test/ambiguous.jl

+16
Original file line numberDiff line numberDiff line change
@@ -447,4 +447,20 @@ cc46601(::Type{T}, x::Int) where {T<:AbstractString} = 7
447447
@test length(methods(cc46601, Tuple{Type{<:Integer}, Integer})) == 2
448448
@test length(Base.methods_including_ambiguous(cc46601, Tuple{Type{<:Integer}, Integer})) == 7
449449

450+
# Issue #55231
451+
struct U55231{P} end
452+
struct V55231{P} end
453+
U55231(::V55231) = nothing
454+
(::Type{T})(::V55231) where {T<:U55231} = nothing
455+
@test length(methods(U55231)) == 2
456+
U55231(a, b) = nothing
457+
@test length(methods(U55231)) == 3
458+
struct S55231{P} end
459+
struct T55231{P} end
460+
(::Type{T})(::T55231) where {T<:S55231} = nothing
461+
S55231(::T55231) = nothing
462+
@test length(methods(S55231)) == 2
463+
S55231(a, b) = nothing
464+
@test length(methods(S55231)) == 3
465+
450466
nothing

0 commit comments

Comments
 (0)