Skip to content

Commit

Permalink
avoid giving useless suggestions for method ambiguities (#33852)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson authored and vtjnash committed Nov 15, 2019
1 parent 7f63f00 commit 1b03919
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 8 additions & 2 deletions base/errorshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,14 @@ function showerror_ambiguous(io::IO, meth, f, args)
sigfix = typeintersect(m.sig, sigfix)
end
if isa(unwrap_unionall(sigfix), DataType) && sigfix <: Tuple
print(io, "\nPossible fix, define\n ")
Base.show_tuple_as_call(io, :function, sigfix)
if all(m->morespecific(sigfix, m.sig), meth)
print(io, "\nPossible fix, define\n ")
Base.show_tuple_as_call(io, :function, sigfix)
else
println(io)
print(io, "To resolve the ambiguity, try making one of the methods more specific, or ")
print(io, "adding a new method more specific than any of the existing applicable methods.")
end
end
nothing
end
Expand Down
4 changes: 3 additions & 1 deletion base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,9 @@ end
Compute a type that contains the intersection of `T` and `S`. Usually this will be the
smallest such type or one close to it.
"""
typeintersect(@nospecialize(a),@nospecialize(b)) = (@_pure_meta; ccall(:jl_type_intersection, Any, (Any,Any), a, b))
typeintersect(@nospecialize(a), @nospecialize(b)) = (@_pure_meta; ccall(:jl_type_intersection, Any, (Any, Any), a, b))

morespecific(@nospecialize(a), @nospecialize(b)) = ccall(:jl_type_morespecific, Cint, (Any, Any), a, b) != 0

"""
fieldoffset(type, i)
Expand Down

0 comments on commit 1b03919

Please sign in to comment.