Skip to content

Commit 7cbe7c1

Browse files
JeffBezansonKristofferC
authored andcommitted
use type inference world in return_type (#30470)
1 parent 5b18d5f commit 7cbe7c1

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

base/compiler/typeinfer.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,12 @@ end
626626

627627

628628
function return_type(@nospecialize(f), @nospecialize(t))
629-
params = Params(ccall(:jl_get_tls_world_age, UInt, ()))
629+
world = ccall(:jl_get_tls_world_age, UInt, ())
630+
return ccall(:jl_call_in_typeinf_world, Any, (Ptr{Ptr{Cvoid}}, Cint), Any[_return_type, f, t, world], 4)
631+
end
632+
633+
function _return_type(@nospecialize(f), @nospecialize(t), world)
634+
params = Params(world)
630635
rt = Union{}
631636
if isa(f, Builtin)
632637
rt = builtin_tfunction(f, Any[t.parameters...], nothing, params)

src/gf.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,16 @@ jl_code_info_t *jl_type_infer(jl_method_instance_t **pli, size_t world, int forc
289289
return src;
290290
}
291291

292+
JL_DLLEXPORT jl_value_t *jl_call_in_typeinf_world(jl_value_t **args, int nargs)
293+
{
294+
jl_ptls_t ptls = jl_get_ptls_states();
295+
size_t last_age = ptls->world_age;
296+
ptls->world_age = jl_typeinf_world;
297+
jl_value_t *ret = jl_apply(args, nargs);
298+
ptls->world_age = last_age;
299+
return ret;
300+
}
301+
292302
int jl_is_rettype_inferred(jl_method_instance_t *li)
293303
{
294304
if (!li->inferred)

0 commit comments

Comments
 (0)