Skip to content

Commit

Permalink
Improve error message for which(fn, types)
Browse files Browse the repository at this point in the history
Error messages for `MethodError` are much more helpful
in determining why the method was not successfully dispatched
than simply "No unique matching method found."

Fixes #47322
  • Loading branch information
apaz-cli committed Oct 27, 2022
1 parent 0c382c2 commit 3992e13
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1505,7 +1505,12 @@ See also: [`parentmodule`](@ref), and `@which` and `@edit` in [`InteractiveUtils
function which(@nospecialize(f), @nospecialize(t))
t = to_tuple_type(t)
tt = signature_type(f, t)
return which(tt)
world = get_world_counter()
match, _ = Core.Compiler._findsup(tt, nothing, world)
if match === nothing
throw(MethodError(f, t, world))
end
return match.method
end

"""
Expand Down

0 comments on commit 3992e13

Please sign in to comment.