@@ -225,9 +225,45 @@ code_native(f::ANY, types::ANY) = code_native(STDOUT, f, types)
225225code_native (io:: IO , f:: ANY , t:: ANY ) =
226226 code_native (io, call, tt_cons (isa (f, Type) ? Type{f} : typeof (f), t))
227227
228- if isdefined (Core, :Inference ) && not_int (is (current_module (), Core. Inference))
229- code_typed (args... ;kwargs... ) = Core. Inference. code_typed (args... ;kwargs... )
230- return_types (args... ;kwargs... ) = Core. Inference. return_types (args... ;kwargs... )
228+ function code_typed (f:: Function , types:: ANY ; optimize= true )
229+ types = to_tuple_type (types)
230+ asts = []
231+ for x in _methods (f,types,- 1 )
232+ linfo = Core. Inference. func_for_method (x[3 ],types,x[2 ])
233+ if optimize
234+ (tree, ty) = Core. Inference. typeinf (linfo, x[1 ], x[2 ], linfo,
235+ true , true )
236+ else
237+ (tree, ty) = Core. Inference. typeinf_uncached (linfo, x[1 ], x[2 ],
238+ optimize= false )
239+ end
240+ if ! isa (tree, Expr)
241+ push! (asts, ccall (:jl_uncompress_ast , Any, (Any,Any), linfo, tree))
242+ else
243+ push! (asts, tree)
244+ end
245+ end
246+ asts
247+ end
248+
249+ function code_typed (f, t:: ANY ; optimize= true )
250+ code_typed (call, tt_cons (isa (f, Type) ? Type{f} : typeof (f), t),
251+ optimize= optimize)
252+ end
253+
254+ function return_types (f:: Function , types:: ANY )
255+ types = to_tuple_type (types)
256+ rt = []
257+ for x in _methods (f,types,- 1 )
258+ linfo = Core. Inference. func_for_method (x[3 ],types,x[2 ])
259+ (tree, ty) = Core. Inference. typeinf (linfo, x[1 ], x[2 ])
260+ push! (rt, ty)
261+ end
262+ rt
263+ end
264+
265+ function return_types (f, t:: ANY )
266+ return_types (call, tt_cons (isa (f, Type) ? Type{f} : typeof (f), t))
231267end
232268
233269function which (f:: ANY , t:: ANY )
0 commit comments