Distinguish external/internal def-ids when converting types

 When decoding types, indicate to the def-id conversion function what kind of def-id we have, so that the inliner can distinguish between external and internal def-ids.  Also add some comments explaining the distinction!

Fixes #4516.

r? @graydon (or anyone)