Construct const fns based on the type, not the definition.

Fixes #5210; unblocks #5183.