How does set_inst_override_by_type work?

In reply to mlsxdx:

You are getting into an infinite loop because you are using the wildcard “*” as the instance name, which is the same as overriding all A class types with B. Then you are creating a B object which contains a B object, which contains a B object.

With class derived from uvm_object, the instance name is just the simple name of the object, so if you change your override to

      A::type_id::set_inst_override(B::get_type(), "A1");

It should work that way you expect it to.