[sv-ec] virtual methods

From: Francoise Martinolle <fm_at_.....>
Date: Thu Dec 17 2009 - 15:12:38 PST
The section on virtual methods states that the prototype of a virtual method in a derived class must match exactly
the prototype of the same method in the base class. An exception is for defaults of arguments where the presence
must match.
What about the qualifiers such as protected, local?
Is the intent to require them to match as well (except for the virtual keyword which is optional in the derived classes)

Ex:
Is this legal?

module test_top();
class foo ;
    virtual protected task run;     // protected in base class
        $display( "base foo is now running" );
    endtask
endclass

class bar extends foo ;
    task run;     //not protected in derived class
        $display( "extended foo is now running" );
    endtask
endclass

foo bc;
foo bcp;
bar ec;

initial begin
    bc = new();
//   bc.run();     //this should get protected method error

    ec = new();
    ec.run();     //this should not get protected method error

    bcp = ec;
    bcp.run();     //But is this a protected method error?
end
endmodule
I think that:
either:
       we should generate a compile error when we find the definition of the task run in the derived class
       and it does not have the "protected" qualifier.

Or  the derived class should inherit the qualifier of the base class method and it would be an error if the derived class method
has an additional different qualifier.

A compile time error over the class method declaration in the derived class is preferred.
The bcp.run() method call appears to be an illegal call to the protected method "run" in the base class.
A special analysis could be done (but would be very complex and difficult) if we would allow such thing as long
as no call to the protected method is found (such as bcp.run() ).
A runtime error is also possible


Francoise
       '


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Thu Dec 17 15:14:22 2009

This archive was generated by hypermail 2.1.8 : Thu Dec 17 2009 - 15:15:15 PST