Skip to content

Commit 99adfb3

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 bd582f7 commit 99adfb3

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

src/gf.c

Lines changed: 1 addition & 1 deletion
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

Lines changed: 16 additions & 0 deletions
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

test/core.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7565,7 +7565,7 @@ end
75657565
# issue #31696
75667566
foo31696(x::Int8, y::Int8) = 1
75677567
foo31696(x::T, y::T) where {T <: Int8} = 2
7568-
@test length(methods(foo31696)) == 1
7568+
@test length(methods(foo31696)) == 2
75697569
let T1 = Tuple{Int8}, T2 = Tuple{T} where T<:Int8, a = T1[(1,)], b = T2[(1,)]
75707570
b .= a
75717571
@test b[1] == (1,)

0 commit comments

Comments
 (0)