Fix for br961 - function return type elaborated in wrong scope.

The return type of a function should be elaborated in the context of
the enclosing scope, not in the context of the function itself.