Fix code generation bug when compiling an object that instantiates or specializes multiple classes