Remove unchecked casts from Types.Builder.

This simplifies the logic so that either a return object is supplied
when a Builder is constructed, or the expected type is supplied so that
the code can check the return type is valid.