Is there a good way to find a function's return type with only the types of its arguments? I mean, I can do something like:
codetyp(code) = code.args[3].typ function returntype(f::Function, types::Tuple) if isgeneric(f) mapreduce(codetyp, Union, code_typed(f, types))::Type else Any end end function returntype(f, types::Tuple) returntype(call, (typeof(f), types...)) end julia> returntype(identity, (Int,)) Int64 julia> returntype(returntype, (Function, Tuple)) Type{T} But is this really reliable? Is there a way to do this other than directly accessing the function's internals?