Fixed bug in cast() where primitive casts like Boolean->boolean would
fail.

Change-Id: I3bc5509968698ad931eb55fce508a1f95fdd1f9b