[when-with-enum] Refactoring of switches codegen