In reply to Tudor Timi:
Tudor,
Thanks for the reply - I did miss the virtual tag on my example. Here’s my corrected full example:
module tb;
interface class base_ic;
pure virtual function base_ic copy(); // does deep copy
endclass
class foo_c implements base_ic;
bit foo;
virtual function foo_c copy();
foo_c cpy;
cpy = new this;
return( cpy );
endfunction
endclass
endmodule
This fails with my simulator. Sounds like this works for you and you believe it’s legal SystemVerilog - Looks like I may need to pursue this problem with my simulation vendor.
To be clear, here’s the same example coded up to use just pure virtual classes as the abstraction mechanism, instead of interface classes:
module tb;
virtual class base_ic;
pure virtual function base_ic copy(); // does deep copy
endclass
class foo_c extends base_ic;
bit foo;
virtual function foo_c copy();
foo_c cpy;
cpy = new this;
return( cpy );
endfunction
endclass
endmodule
You’ll note, the covariant return type (thanks for the terminology!) in the concrete class method.
This second example works in my simulator. The first doesn’t.
Regards,
Mark