Skip to content

Commit d261644

Browse files
committed
Add test for #18888.
1 parent f2f2491 commit d261644

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/reflection.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,3 +573,20 @@ end
573573
@test counter18434 == 1
574574
@which get_A18434()(1, y=2)
575575
@test counter18434 == 2
576+
577+
# PR #18888: code_typed shouldn't cache if not optimizing
578+
let
579+
f18888() = return nothing
580+
m = first(methods(f18888, Tuple{}))
581+
@test m.specializations == nothing
582+
ft = typeof(f18888)
583+
584+
code_typed(f18888, Tuple{}; optimize=false)
585+
@test m.specializations != nothing # uncached, but creates the specializations entry
586+
code = Core.Inference.code_for_method(m, Tuple{ft}, Core.svec(), true)
587+
@test !isdefined(code, :inferred)
588+
589+
code_typed(f18888, Tuple{}; optimize=true)
590+
code = Core.Inference.code_for_method(m, Tuple{ft}, Core.svec(), true)
591+
@test isdefined(code, :inferred)
592+
end

0 commit comments

Comments
 (0)