@@ -216,9 +216,45 @@ code_native(f::ANY, types::ANY) = code_native(STDOUT, f, types)
216216code_native (io:: IO , f:: ANY , t:: ANY ) =
217217 code_native (io, call, tt_cons (isa (f, Type) ? Type{f} : typeof (f), t))
218218
219- if isdefined (Core, :Inference ) && not_int (is (current_module (), Core. Inference))
220- code_typed (args... ;kwargs... ) = Core. Inference. code_typed (args... ;kwargs... )
221- return_types (args... ;kwargs... ) = Core. Inference. return_types (args... ;kwargs... )
219+ function code_typed (f:: Function , types:: ANY ; optimize= true )
220+ types = to_tuple_type (types)
221+ asts = []
222+ for x in _methods (f,types,- 1 )
223+ linfo = Core. Inference. func_for_method (x[3 ],types,x[2 ])
224+ if optimize
225+ (tree, ty) = Core. Inference. typeinf (linfo, x[1 ], x[2 ], linfo,
226+ true , true )
227+ else
228+ (tree, ty) = Core. Inference. typeinf_uncached (linfo, x[1 ], x[2 ],
229+ optimize= false )
230+ end
231+ if ! isa (tree, Expr)
232+ push! (asts, ccall (:jl_uncompress_ast , Any, (Any,Any), linfo, tree))
233+ else
234+ push! (asts, tree)
235+ end
236+ end
237+ asts
238+ end
239+
240+ function code_typed (f, t:: ANY ; optimize= true )
241+ code_typed (call, tt_cons (isa (f, Type) ? Type{f} : typeof (f), t),
242+ optimize= optimize)
243+ end
244+
245+ function return_types (f:: Function , types:: ANY )
246+ types = to_tuple_type (types)
247+ rt = []
248+ for x in _methods (f,types,- 1 )
249+ linfo = Core. Inference. func_for_method (x[3 ],types,x[2 ])
250+ (tree, ty) = Core. Inference. typeinf (linfo, x[1 ], x[2 ])
251+ push! (rt, ty)
252+ end
253+ rt
254+ end
255+
256+ function return_types (f, t:: ANY )
257+ return_types (call, tt_cons (isa (f, Type) ? Type{f} : typeof (f), t))
222258end
223259
224260function which (f:: ANY , t:: ANY )
0 commit comments