Make castItem() successful with primitive types