Overriding build_phase

I have a base test and build phase for that as follows

class base_test extends uvm_test; 

  //Registering test
  `uvm_component_utils(base_test)
  
  bist_env m_env;

  function new(string name, uvm_component parent);
    super.new(name, parent);
  endfunction : new

  //test class methods
  extern virtual function void build_phase(uvm_phase phase);
  extern virtual function void connect_phase(uvm_phase phase);
  extern virtual function void end_of_elaboration_phase(uvm_phase phase);
  extern virtual task run_phase(uvm_phase phase);

endclass : base_test


//Define methods here
function void base_test :: build_phase(uvm_phase phase);
  super.build_phase(phase);
  
  m_env = bist_env::type_id::create("env",this);
endfunction : build_phase

I am trying to extend this base class and build a new test class with overridden build_phase

class selfchk_test extends base_test;
    
  //Registering test
  `uvm_component_utils(selfchk_test)
  
  function new(string name, uvm_component parent);
    super.new(name, parent);
  endfunction : new

  //Declare the sequence
  selfcheck_virtual_sequence vir_seq;

  //class methods
  extern virtual function void build_phase(uvm_phase phase);
  extern virtual task run_phase(uvm_phase phase);

endclass : selfchk_test

function void selfchk_test :: build_phase(uvm_phase phase);
  super.build_phase(phase);

  m_env = bist_env::type_id::create("env",this);
  uvm_config_db#(uvm_active_passive_enum) :: set(this, "m_env.r_agent", "is_active", UVM_ACTIVE);
endfunction : build_phase

But I face following error message

UVM_INFO @ 0: reporter [RNTST] Running test selfchk_test…
UVM_FATAL /home/ip/shared/external/uvm/1.2/54853456/snps/2019.06-SP2-10-T-20210305/src/base/uvm_component.svh(1902) @ 0: env [CLDEXT] Cannot set ‘env’ as a child of ‘uvm_test_top’, which already has a child by that name.

So I understood that the simulator is building 2 env instances with name “env”.

Why is this happening? Shouldn’t the selfchk_test’s build_phase override base_test’s build_phase?

In reply to bachan21:

In the base test build phase env is already created, so in the selfchk_test build phase when super.build_phase is called env will get created, again you need to create it in the extended test class.

Regards,
Shanthi

In reply to shanthi:

Yes. I got the issue.
In super.build_phase bist_env is created with name “env”. So when I try to create another instance with same name, it creates issue. I verified this issue by printing the topology.
Thanks :)

In reply to bachan21:
In the base test build phase env is already created, so in the selfchk_test build phase when super.build_phase is called env will get created, again you need to create it in the extended test class.
Regards,
Shanthi