compiler/types: Tidy up the asserts in get_*_instance functions
Use the local variable in the assertions, move them out the critical region. No behavior change.
Use the local variable in the assertions, move them out the critical region. No behavior change.