Automatically detecting which item from the Union is used