Skip to content

Commit

Permalink
use type inference world in return_type (#30470)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson authored and KristofferC committed Feb 4, 2019
1 parent 5b18d5f commit 7cbe7c1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
7 changes: 6 additions & 1 deletion base/compiler/typeinfer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,12 @@ end


function return_type(@nospecialize(f), @nospecialize(t))
params = Params(ccall(:jl_get_tls_world_age, UInt, ()))
world = ccall(:jl_get_tls_world_age, UInt, ())
return ccall(:jl_call_in_typeinf_world, Any, (Ptr{Ptr{Cvoid}}, Cint), Any[_return_type, f, t, world], 4)
end

function _return_type(@nospecialize(f), @nospecialize(t), world)
params = Params(world)
rt = Union{}
if isa(f, Builtin)
rt = builtin_tfunction(f, Any[t.parameters...], nothing, params)
Expand Down
10 changes: 10 additions & 0 deletions src/gf.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,16 @@ jl_code_info_t *jl_type_infer(jl_method_instance_t **pli, size_t world, int forc
return src;
}

JL_DLLEXPORT jl_value_t *jl_call_in_typeinf_world(jl_value_t **args, int nargs)
{
jl_ptls_t ptls = jl_get_ptls_states();
size_t last_age = ptls->world_age;
ptls->world_age = jl_typeinf_world;
jl_value_t *ret = jl_apply(args, nargs);
ptls->world_age = last_age;
return ret;
}

int jl_is_rettype_inferred(jl_method_instance_t *li)
{
if (!li->inferred)
Expand Down

0 comments on commit 7cbe7c1

Please sign in to comment.