Provide a way to get the inferred return type of a function

This PR implements `Base.return_type(function, types)` to get the inferred return type of a function for a given set of input types. Type inference knows about `Base.return_type`, and when the function and types are known at compile time, the call can be eliminated entirely.

This would make it possible to provide type inference for memoized functions, and it is the proper way to provide the right typeassert for the FFT inverse in #6193. It could also be used to determine the element type of the returned array for `map` and `broadcast (see also #210, #670, #2938, #4883, #6548, and others), although for `map` the overhead might be undesirable, and there is some debate over whether making the concrete output types of functions depend on type inference is a good idea.

I am not entirely confident in the correctness of this code, so if this functionality is useful enough to include it, please take a close look.