From 8c3ab9fdce32d09df81c8a678d564b82195b22e7 Mon Sep 17 00:00:00 2001 From: Shuhei Kadowaki Date: Wed, 3 Apr 2024 13:15:22 +0900 Subject: [PATCH] more fixes --- base/reflection.jl | 9 ++++++--- stdlib/InteractiveUtils/src/codeview.jl | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/base/reflection.jl b/base/reflection.jl index 8176fb5223dfc..2df713a531fae 100644 --- a/base/reflection.jl +++ b/base/reflection.jl @@ -1639,8 +1639,10 @@ function code_typed_by_type(@nospecialize(tt::Type); return asts end -function get_oc_code_rt(@nospecialize(oc::Core.OpaqueClosure), types=Tuple, optimize::Bool=true) - ccall(:jl_is_in_pure_context, Bool, ()) && error("code reflection cannot be used from generated functions") +function get_oc_code_rt(oc::Core.OpaqueClosure, types, optimize::Bool) + @nospecialize oc types + ccall(:jl_is_in_pure_context, Bool, ()) && + error("code reflection cannot be used from generated functions") m = oc.source if isa(m, Method) if isdefined(m, :source) @@ -1663,10 +1665,11 @@ function get_oc_code_rt(@nospecialize(oc::Core.OpaqueClosure), types=Tuple, opti end end -function code_typed_opaque_closure(@nospecialize(oc::Core.OpaqueClosure), types=Tuple; +function code_typed_opaque_closure(oc::Core.OpaqueClosure, types; debuginfo::Symbol=:default, optimize::Bool=true, _...) + @nospecialize oc types (code, rt) = get_oc_code_rt(oc, types, optimize) debuginfo === :none && remove_linenums!(code) return Any[Pair{CodeInfo,Any}(code, rt)] diff --git a/stdlib/InteractiveUtils/src/codeview.jl b/stdlib/InteractiveUtils/src/codeview.jl index d03e2b27a2286..b242dea8e006e 100644 --- a/stdlib/InteractiveUtils/src/codeview.jl +++ b/stdlib/InteractiveUtils/src/codeview.jl @@ -143,7 +143,7 @@ See the [`@code_warntype`](@ref man-code-warntype) section in the Performance Ti See also: [`@code_warntype`](@ref), [`code_typed`](@ref), [`code_lowered`](@ref), [`code_llvm`](@ref), [`code_native`](@ref). """ -function code_warntype(io::IO, @nospecialize(f), @nospecialize(t=Base.default_tt(f)); +function code_warntype(io::IO, @nospecialize(f), @nospecialize(tt=Base.default_tt(f)); world=Base.get_world_counter(), interp::Core.Compiler.AbstractInterpreter=Core.Compiler.NativeInterpreter(world), debuginfo::Symbol=:default, optimize::Bool=false, kwargs...) @@ -154,10 +154,10 @@ function code_warntype(io::IO, @nospecialize(f), @nospecialize(t=Base.default_tt nargs::Int = 0 if isa(f, Core.OpaqueClosure) isa(f.source, Method) && (nargs = f.nargs) - print_warntype_codeinfo(io, Base.code_typed_opaque_closure(f)[1]..., nargs; lineprinter) + print_warntype_codeinfo(io, Base.code_typed_opaque_closure(f, tt)[1]..., nargs; lineprinter) return nothing end - matches = Base._methods_by_ftype(Base.signature_type(f, t), #=lim=#-1, world)::Vector + matches = Base._methods_by_ftype(Base.signature_type(f, tt), #=lim=#-1, world)::Vector for match in matches match = match::Core.MethodMatch (src, rettype) = Core.Compiler.typeinf_code(interp, match, optimize)