Collapse conditional and add an assert for unhandled scope types.