Forbid use of generics with foreign functions. Closes #10353.

and fix up some formatting.