Skip to content

Commit cc694e4

Browse files
vtjnashKristofferC
authored and
KristofferC
committed
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 b29b9b5 commit cc694e4

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
@@ -3436,7 +3436,7 @@ static int sort_mlmatches(jl_array_t *t, size_t idx, arraylist_t *visited, array
34363436
int msp2 = !msp && jl_type_morespecific((jl_value_t*)m2->sig, (jl_value_t*)m->sig);
34373437
if (!msp) {
34383438
if (subt || !include_ambiguous || (lim != -1 && msp2)) {
3439-
if (subt2 || jl_subtype((jl_value_t*)ti, m2->sig)) {
3439+
if (subt2 || ((lim != -1 || (!include_ambiguous && !msp2)) && jl_subtype((jl_value_t*)ti, m2->sig))) {
34403440
// this may be filtered out as fully intersected, if applicable later
34413441
mayexclude = 1;
34423442
}

test/ambiguous.jl

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

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

test/core.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7554,7 +7554,7 @@ end
75547554
# issue #31696
75557555
foo31696(x::Int8, y::Int8) = 1
75567556
foo31696(x::T, y::T) where {T <: Int8} = 2
7557-
@test length(methods(foo31696)) == 1
7557+
@test length(methods(foo31696)) == 2
75587558
let T1 = Tuple{Int8}, T2 = Tuple{T} where T<:Int8, a = T1[(1,)], b = T2[(1,)]
75597559
b .= a
75607560
@test b[1] == (1,)

0 commit comments

Comments
 (0)