Remove unsafe casts to union types am: 1361d5216b
am: c52adb48c5

Change-Id: I2ce2a73b502078c5fc1cd43cd15020a9eafce9a0