Remove unsafe casts to union types
am: 1361d5216b

Change-Id: I17dc037cd611c843c104791b2be829c11ffa56e9