Skip to content

Commit a94e6e2

Browse files
authored
Use Cached type inference (#653)
1 parent 8eeee3b commit a94e6e2

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/validation.jl

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,18 @@ function method_matches(@nospecialize(tt::Type{<:Tuple}); world::Integer)
1414
end
1515

1616
function typeinf_type(mi::MethodInstance; interp::CC.AbstractInterpreter)
17-
ty = Core.Compiler.typeinf_type(interp, mi.def, mi.specTypes, mi.sparam_vals)
18-
return something(ty, Any)
17+
@static if VERSION < v"1.11.0"
18+
code = Core.Compiler.get(Core.Compiler.code_cache(interp), mi, nothing)
19+
if code isa Core.Compiler.CodeInstance
20+
return code.rettype
21+
end
22+
result = Core.Compiler.InferenceResult(mi, Core.Compiler.typeinf_lattice(interp))
23+
Core.Compiler.typeinf(interp, result, :global)
24+
Core.Compiler.is_inferred(result) || return Any
25+
Core.Compiler.widenconst(Core.Compiler.ignorelimited(result.result))
26+
else
27+
something(Core.Compiler.typeinf_type(interp, mi), Any)
28+
end
1929
end
2030

2131
function check_method(@nospecialize(job::CompilerJob))

0 commit comments

Comments
 (0)