Skip to content

Commit 4e71dcc

Browse files
maleadtjohanmon
authored andcommitted
Add world age and interpreter arguments to code_warntype. (JuliaLang#41149)
1 parent 09b156a commit 4e71dcc

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

stdlib/InteractiveUtils/src/codeview.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,11 @@ Keyword argument `debuginfo` may be one of `:source` or `:none` (default), to sp
5757
5858
See [`@code_warntype`](@ref man-code-warntype) for more information.
5959
"""
60-
function code_warntype(io::IO, @nospecialize(f), @nospecialize(t); debuginfo::Symbol=:default, optimize::Bool=false)
60+
function code_warntype(io::IO, @nospecialize(f), @nospecialize(t);
61+
debuginfo::Symbol=:default, optimize::Bool=false, kwargs...)
6162
debuginfo = Base.IRShow.debuginfo(debuginfo)
6263
lineprinter = Base.IRShow.__debuginfo[debuginfo]
63-
for (src, rettype) in code_typed(f, t, optimize=optimize)
64+
for (src, rettype) in code_typed(f, t; optimize, kwargs...)
6465
lambda_io::IOContext = io
6566
p = src.parent
6667
nargs::Int = 0

test/reflection.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -936,3 +936,19 @@ end
936936
@test f !== Core._apply
937937
@test occursin("f2#", String(nameof(f)))
938938
end
939+
940+
941+
@testset "code_typed(; world)" begin
942+
mod = @eval module $(gensym()) end
943+
944+
@eval mod foo() = 1
945+
world1 = Base.get_world_counter()
946+
@test only(code_typed(mod.foo, ())).second == Int
947+
@test only(code_typed(mod.foo, (); world=world1)).second == Int
948+
949+
@eval mod foo() = 2.
950+
world2 = Base.get_world_counter()
951+
@test only(code_typed(mod.foo, ())).second == Float64
952+
@test only(code_typed(mod.foo, (); world=world1)).second == Int
953+
@test only(code_typed(mod.foo, (); world=world2)).second == Float64
954+
end

0 commit comments

Comments
 (0)