Skip to content
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
4 changes: 2 additions & 2 deletions src/gf.c
Original file line number Diff line number Diff line change
Expand Up @@ -3370,7 +3370,7 @@ static int sort_mlmatches(jl_array_t *t, size_t idx, arraylist_t *visited, array
continue; // already part of this cycle
jl_method_match_t *matc2 = (jl_method_match_t*)jl_array_ptr_ref(t, childidx);
jl_method_t *m2 = matc2->method;
int subt2 = matc2->fully_covers != NOT_FULLY_COVERS; // jl_subtype((jl_value_t*)type, (jl_value_t*)m2->sig)
int subt2 = matc2->fully_covers == FULLY_COVERS; // jl_subtype((jl_value_t*)type, (jl_value_t*)m2->sig)
// TODO: we could change this to jl_has_empty_intersection(ti, (jl_value_t*)matc2->spec_types);
// since we only care about sorting of the intersections the user asked us about
if (!subt2 && jl_has_empty_intersection(m2->sig, m->sig))
Expand Down Expand Up @@ -3515,7 +3515,7 @@ static int sort_mlmatches(jl_array_t *t, size_t idx, arraylist_t *visited, array
size_t idx2 = (size_t)stack->items[j];
jl_method_match_t *matc2 = (jl_method_match_t*)jl_array_ptr_ref(t, idx2);
jl_method_t *m2 = matc2->method;
int subt2 = matc2->fully_covers != NOT_FULLY_COVERS; // jl_subtype((jl_value_t*)type, (jl_value_t*)m2->sig)
int subt2 = matc2->fully_covers == FULLY_COVERS; // jl_subtype((jl_value_t*)type, (jl_value_t*)m2->sig)
// if their intersection contributes to the ambiguity cycle
// and the contribution of m is fully ambiguous with the portion of the cycle from m2
if (subt2 || jl_subtype((jl_value_t*)ti, m2->sig)) {
Expand Down
24 changes: 24 additions & 0 deletions test/ambiguous.jl
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,30 @@ for f in (Ambig8.f, Ambig8.g)
@test f(Int8(0)) == 4
@test_throws MethodError f(0)
@test_throws MethodError f(pi)
let ambig = Ref{Int32}(0)
ms = Base._methods_by_ftype(Tuple{typeof(f), Union{Int,AbstractIrrational}}, nothing, 10, Base.get_world_counter(), false, Ref{UInt}(typemin(UInt)), Ref{UInt}(typemax(UInt)), ambig)
@test ms isa Vector
@test length(ms) == 2
@test ambig[] == 1
end
let ambig = Ref{Int32}(0)
ms = Base._methods_by_ftype(Tuple{typeof(f), Union{Int,AbstractIrrational}}, nothing, -1, Base.get_world_counter(), false, Ref{UInt}(typemin(UInt)), Ref{UInt}(typemax(UInt)), ambig)
@test ms isa Vector
@test length(ms) == 2
@test ambig[] == 1
end
let ambig = Ref{Int32}(0)
ms = Base._methods_by_ftype(Tuple{typeof(f), Union{Int,AbstractIrrational}}, nothing, 10, Base.get_world_counter(), true, Ref{UInt}(typemin(UInt)), Ref{UInt}(typemax(UInt)), ambig)
@test ms isa Vector
@test length(ms) == 3
@test ambig[] == 1
end
let ambig = Ref{Int32}(0)
ms = Base._methods_by_ftype(Tuple{typeof(f), Union{Int,AbstractIrrational}}, nothing, -1, Base.get_world_counter(), true, Ref{UInt}(typemin(UInt)), Ref{UInt}(typemax(UInt)), ambig)
@test ms isa Vector
@test length(ms) == 3
@test ambig[] == 1
end
end

module Ambig9
Expand Down