Abstract methods, interface class, and virtual methods

In reply to Mark Curry:

I tried your example and it didn’t compile initially. I got a ‘does not implement method in interface error’. I changed it up a bit by explicitly declaring the class function as ‘virtual’:


class foo_c implements base_ic;
  bit foo;

  virtual function foo_c copy();
    // ...
  endfunction

endclass

This way it worked.

The error message I initially got is different that what you were getting, so I guess we’re using different tools. Since this is allowed for regular classes, you would expect this to work with interface classes as well, right? I assume this is the intention (since Java provides the same mechanism), but the tool vendors tend to have their own interpretations.

Note: returning a more specific type from a function is called a covariant return type.