Issue with set_inst_override_by_type

I am trying to override drive with another driver. both are dervied from uvm-driver but i get fatal error

error:UVM_FATAL @ 0: reporter [FCTTYP] Factory did not return a component of type ‘adpcm_driver’. A component of type ‘adpcm_driver1’ was returned instead. Name=m_driver Parent=adpcm_test contxt=uvm_test_top

code:

factory.set_inst_override_by_type(adpcm_driver::get_type(),adpcm_driver1::get_type(),$sformatf(“*.m_driver”));
m_driver = adpcm_driver::type_id::create(“m_driver”, this);
m_sequencer = adpcm_sequencer::type_id::create(“m_sequencer”, this);

can anyone help me with this.

In reply to akhandelwal07:

The error is saying that the assignment from $cast to the handle type has been failed. Overriding is just an enhanced concept of polymorphism. Factory can return an object of extended class when a parent class object is requested. Make sure that “adpcm_driver1” is extended from “adpcm_driver” class in order to have a successful casting. Also make sure that both the classes are correctly registered with factory.