Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk committed Apr 3, 2024
1 parent e5cfb9b commit 8c3ab9f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
9 changes: 6 additions & 3 deletions base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)]
Expand Down
6 changes: 3 additions & 3 deletions stdlib/InteractiveUtils/src/codeview.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand All @@ -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)
Expand Down

0 comments on commit 8c3ab9f

Please sign in to comment.