Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ml-matches: ensure all methods are included #55365

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/gf.c
Original file line number Diff line number Diff line change
Expand Up @@ -3669,7 +3669,7 @@ static int sort_mlmatches(jl_array_t *t, size_t idx, arraylist_t *visited, array
int msp2 = !msp && jl_method_morespecific(m2, m);
if (!msp) {
if (subt || !include_ambiguous || (lim != -1 && msp2)) {
if (subt2 || jl_subtype((jl_value_t*)ti, m2->sig)) {
if (subt2 || ((lim != -1 || (!include_ambiguous && !msp2)) && jl_subtype((jl_value_t*)ti, m2->sig))) {
// this may be filtered out as fully intersected, if applicable later
mayexclude = 1;
}
Expand Down
16 changes: 16 additions & 0 deletions test/ambiguous.jl
Original file line number Diff line number Diff line change
Expand Up @@ -447,4 +447,20 @@ cc46601(::Type{T}, x::Int) where {T<:AbstractString} = 7
@test length(methods(cc46601, Tuple{Type{<:Integer}, Integer})) == 2
@test length(Base.methods_including_ambiguous(cc46601, Tuple{Type{<:Integer}, Integer})) == 7

# Issue #55231
struct U55231{P} end
struct V55231{P} end
U55231(::V55231) = nothing
(::Type{T})(::V55231) where {T<:U55231} = nothing
@test length(methods(U55231)) == 2
U55231(a, b) = nothing
@test length(methods(U55231)) == 3
struct S55231{P} end
struct T55231{P} end
(::Type{T})(::T55231) where {T<:S55231} = nothing
S55231(::T55231) = nothing
@test length(methods(S55231)) == 2
S55231(a, b) = nothing
@test length(methods(S55231)) == 3

nothing
2 changes: 1 addition & 1 deletion test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7565,7 +7565,7 @@ end
# issue #31696
foo31696(x::Int8, y::Int8) = 1
foo31696(x::T, y::T) where {T <: Int8} = 2
@test length(methods(foo31696)) == 1
@test length(methods(foo31696)) == 2
let T1 = Tuple{Int8}, T2 = Tuple{T} where T<:Int8, a = T1[(1,)], b = T2[(1,)]
b .= a
@test b[1] == (1,)
Expand Down