Skip to content

Commit 84139ed

Browse files
vtjnashKristofferC
authored andcommitted
ml-matches: ensure all methods are included (#55365)
Some methods were filtered out based simply on visit order, which was not intentional, with the lim==-1 weak-edges mode. Fix #55231 (cherry picked from commit 1db5cf7)
1 parent 21ccfc0 commit 84139ed

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
@@ -3385,7 +3385,7 @@ static int sort_mlmatches(jl_array_t *t, size_t idx, arraylist_t *visited, array
33853385
int msp2 = !msp && jl_type_morespecific((jl_value_t*)m2->sig, (jl_value_t*)m->sig);
33863386
if (!msp) {
33873387
if (subt || !include_ambiguous || (lim != -1 && msp2)) {
3388-
if (subt2 || jl_subtype((jl_value_t*)ti, m2->sig)) {
3388+
if (subt2 || ((lim != -1 || (!include_ambiguous && !msp2)) && jl_subtype((jl_value_t*)ti, m2->sig))) {
33893389
// this may be filtered out as fully intersected, if applicable later
33903390
mayexclude = 1;
33913391
}

test/ambiguous.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,4 +427,20 @@ cc46601(::Type{T}, x::Int) where {T<:AbstractString} = 7
427427
@test length(methods(cc46601, Tuple{Type{<:Integer}, Integer})) == 2
428428
@test length(Base.methods_including_ambiguous(cc46601, Tuple{Type{<:Integer}, Integer})) == 7
429429

430+
# Issue #55231
431+
struct U55231{P} end
432+
struct V55231{P} end
433+
U55231(::V55231) = nothing
434+
(::Type{T})(::V55231) where {T<:U55231} = nothing
435+
@test length(methods(U55231)) == 2
436+
U55231(a, b) = nothing
437+
@test length(methods(U55231)) == 3
438+
struct S55231{P} end
439+
struct T55231{P} end
440+
(::Type{T})(::T55231) where {T<:S55231} = nothing
441+
S55231(::T55231) = nothing
442+
@test length(methods(S55231)) == 2
443+
S55231(a, b) = nothing
444+
@test length(methods(S55231)) == 3
445+
430446
nothing

test/core.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7542,7 +7542,7 @@ end
75427542
# issue #31696
75437543
foo31696(x::Int8, y::Int8) = 1
75447544
foo31696(x::T, y::T) where {T <: Int8} = 2
7545-
@test length(methods(foo31696)) == 1
7545+
@test length(methods(foo31696)) == 2
75467546
let T1 = Tuple{Int8}, T2 = Tuple{T} where T<:Int8, a = T1[(1,)], b = T2[(1,)]
75477547
b .= a
75487548
@test b[1] == (1,)

0 commit comments

Comments
 (0)