extends builds a child class on a parent. Mark methods virtual so a child override runs when the handle type is the parent.
flowchart TB base[base_txn] --> child[error_txn] virt["virtual do_item()"] --> override[override in child]
class base_txn;
virtual function void stringify();
$display("base");
endfunction
endclass
class err_txn extends base_txn;
virtual function void stringify();
$display("error");
endfunction
endclass
UVM factories swap types at runtime; they only work cleanly if create / type_id sit on classes with virtual APIs.
Wrong vs right
Wrong — non-virtual method, then expect a child override through a base handle.
Right — virtual on methods you intend to override; $cast when you need child members.