From 3992e138a22d4c6db5444b8ed5773c9a72f2c7cf Mon Sep 17 00:00:00 2001 From: apaz-cli Date: Thu, 27 Oct 2022 18:08:23 -0500 Subject: [PATCH] Improve error message for `which(fn, types)` 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 --- base/reflection.jl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/base/reflection.jl b/base/reflection.jl index 3c5887ec8dfb6e..f85df3d3b43911 100644 --- a/base/reflection.jl +++ b/base/reflection.jl @@ -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 """