emit cast for invoke since invoke can only return Object or primitives