Overriding non-virtual task

Hello Forum,
I am trying to override one of the non-virtual tasks defined in base class to implement some additional logic. Here is my attempt edaplayground

I have a few questions

(1) Without any +define I observe the output as

Within run_phase() of ext_wr_driver
Within task1 of ext_wr_driver
Within task2 of ext_wr_driver

(Q1_a) Why isn’t ext_wr_driver::task2() called ? ( since I don’t observe “Within overridden task2 of ext_wr_driver” )

(2) I then passed +define+OVERRIDE_RUN_PH, I finally observe my overridden task being called

(Q2_a) How does overriding virtual ‘run_phase’ help in calling the overridden task2 ?

Your output is misleading you because get_type_name() is virtual.

Hi Dave,
Yes,I do understand that (1) ends up calling the 2 tasks defined in base class.
However, I am not clear on the reason behind it.
Since the extended class inherits virtual task run_phase, I expected (1) to internally operate as if ‘run_phase’ is explicitly defined in extended class as

virtual task run_phase();
    $display("Within run_phase() of %0s",get_type_name());
    fork
      task1();
      task2(); // Intention is to call my overridden task
      // Calls the non-virtual tasks in base class
    join      
  endtask

Why is that only when I explicitly override the virtual task ‘run_phase’ ( via +define+OVERRIDE_RUN_PH ), the intended ‘task2’ gets called ?

Your code in the base class has no access to anything in the extended classes except for virtual methods. Once inside an overridden virtual method, it has access to everything in the derived class.