How to perform a parametrized extended class override?

Hello,
I would like to know if it is possible in the factory to use set_type_override on a parametrized extended class (to override both class and parameter types). I currently use OVM libraries.
In my example below the goal is to keep driver_generic generic so I don’t want it to be dependent of a specific transaction.
My example compile but I have this FATAL message at run time :

OVM_FATAL @ 0: reporter [FCTTYP] Factory did not return a component of type ‘driver_generic’. A component of type ‘ab_cd_driver’ was returned instead. Name=drv Parent=agent_generic contxt=ovm_test_top.env_h.ab_cd_agent_h

Thank you for your explanations.


class inputnop_tran extends ovm_sequence_item;
...

class driver_generic #(type P = ovm_sequence_item) extends ovm_driver #(P);
...

class ab_cd_driver #(type P = inputnop_tran) extends driver_generic #(P);
...

class agent_generic extends ovm_agent;
  ...
  driver_generic     drv;
  ...
  
  function void build;
    super.build();
    ...
    drv = driver_generic#()::type_id::create("drv", this);
    ...
  endfunction : build
  ...
endclass : agent_generic

class environment extends ovm_env;
  ...
  agent_generic       ab_cd_agent_h;
  ...
  
  function void build;
    super.build();
    ...    
    ab_cd_agent_h       = agent_generic::type_id::create("ab_cd_agent_h", this);
    // Type override
    driver_generic#(ovm_sequence_item)::type_id::set_type_override(ab_cd_driver#(inputnop_tran)::get_type());
  endfunction : build
  ...
endclass : environment

In reply to aaubertin:
The factory only works when your override shares the same base class and unfortunately for you,
driver_generic#(ovm_sequence_item)
is not the same base class as
driver_generic#(inputnop_tran)
. Another problem is that in order to use any virtual methods in your generic base class, they have to share the same prototype in the extended classed. So this means your common base class needs to share the same parameterizations, or be unparameterized. So this means creating a common base class for your ovm_sequence_item, or making your generic driver un-parameterized.

In reply to dave_59:

I have found a way to make my driver_generic and ab_cd_driver unparameterized and my override problem is solved. Thank you !