[sv-ec] Name resolution in nested classes

From: Mark Hartoog <Mark.Hartoog@synopsys.com>
Date: Thu Nov 17 2011 - 17:41:59 PST

An issue recently came up and I am wondering if other people agree with my understanding of the how name resolution works in nested classes.

LRM section 8.22 Class scope resolution operator ::

"Nested classes shall have the same access rights as methods do in the containing class. They have full access
rights to local and protected methods and properties of the containing class. Nested classes have lexically-
scoped, unqualified access to the static properties and methods, parameters, and local parameters of
the containing class. They shall not have implicit access to non-static properties and methods except through
a handle either passed to it or otherwise accessible by it. There is no implicit this handle to the outer class."

Consider this case:

module test;
int x = 1;
class Outer;
   int x = 2;
   class Inner;
      static function int getX();
          return x; // is this illegal?
      endfunction
   endclass
endclass
initial $display(Outer::Inner::getX());
endmodule

My understanding is that this 'x' in Outer::Inner::getX() is an illegal attempt to access a non-static outer class field. The field 'x' in Outer is lexically visible in the class Inner, but the class Inner does not have access rights to the non-static field.

Someone has tried to suggest to me that what the LRM meant is that the non-static methods and fields are not visible in the inner class, and then the 'x' should bind to the module level variable 'x'.

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Thu Nov 17 17:42:32 2011

This archive was generated by hypermail 2.1.8 : Thu Nov 17 2011 - 17:42:39 PST