Skip to content

Commit ef5545f

Browse files
committed
use type inference world in return_type
1 parent 8b1bf4c commit ef5545f

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
@@ -633,7 +633,12 @@ end
633633

634634

635635
function return_type(@nospecialize(f), @nospecialize(t))
636-
params = Params(ccall(:jl_get_tls_world_age, UInt, ()))
636+
world = ccall(:jl_get_tls_world_age, UInt, ())
637+
return ccall(:jl_call_in_typeinf_world, Any, (Ptr{Ptr{Cvoid}}, Cint), Any[_return_type, f, t, world], 4)
638+
end
639+
640+
function _return_type(@nospecialize(f), @nospecialize(t), world)
641+
params = Params(world)
637642
rt = Union{}
638643
if isa(f, Builtin)
639644
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
@@ -300,6 +300,16 @@ jl_code_info_t *jl_type_infer(jl_method_instance_t **pli JL_ROOTS_TEMPORARILY, s
300300
return src;
301301
}
302302

303+
JL_DLLEXPORT jl_value_t *jl_call_in_typeinf_world(jl_value_t **args, int nargs)
304+
{
305+
jl_ptls_t ptls = jl_get_ptls_states();
306+
size_t last_age = ptls->world_age;
307+
ptls->world_age = jl_typeinf_world;
308+
jl_value_t *ret = jl_apply(args, nargs);
309+
ptls->world_age = last_age;
310+
return ret;
311+
}
312+
303313
int jl_is_rettype_inferred(jl_method_instance_t *li) JL_NOTSAFEPOINT
304314
{
305315
if (!li->inferred)

0 commit comments

Comments
 (0)