From df22587b3a8c5b03ffcf3ce4407c0a076a39d4b5 Mon Sep 17 00:00:00 2001 From: Em Chu Date: Fri, 10 Oct 2025 16:43:03 -0700 Subject: [PATCH] Clarify docstring, rm inconsistent check for `hasmethod` --- base/reflection.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/base/reflection.jl b/base/reflection.jl index b9a8af211bf44..ae2f117e2c597 100644 --- a/base/reflection.jl +++ b/base/reflection.jl @@ -1030,7 +1030,8 @@ parentmodule(m::Method) = m.module hasmethod(f, t::Type{<:Tuple}[, kwnames]; world=get_world_counter())::Bool Determine whether the given generic function has a method matching the given -`Tuple` of argument types with the upper bound of world age given by `world`. +`Tuple` of argument types in the world age given by `world`. Note that this is +always false when `world` is greater than the current latest world. If a tuple of keyword argument names `kwnames` is provided, this also checks whether the method of `f` matching `t` has the given keyword argument names. @@ -1073,7 +1074,6 @@ end function hasmethod(f, t, kwnames::Tuple{Vararg{Symbol}}; world::UInt=get_world_counter()) @nospecialize - world == typemax(UInt) && error("code reflection cannot be used from generated functions") isempty(kwnames) && return hasmethod(f, t; world) t = to_tuple_type(t) ft = Core.Typeof(f)