<?xml version="1.0"?>
<clause number="14.5.2" title="Simple names">
  <paragraph>A <non_terminal where="14.5.2">simple-name</non_terminal> consists of a single identifier. <grammar_production><name><non_terminal where="14.5.2">simple-name</non_terminal></name> : <rhs><non_terminal where="9.4.2">identifier</non_terminal></rhs></grammar_production></paragraph>
  <paragraph>A <non_terminal where="14.5.2">simple-name</non_terminal> is evaluated and classified as follows: <list><list_item> If the <non_terminal where="14.5.2">simple-name</non_terminal> appears within a block and if the block's (or an enclosing block's) local variable declaration space (<hyperlink>10.3</hyperlink>) contains a local variable or parameter with the given name, then the <non_terminal where="14.5.2">simple-name</non_terminal> refers to that local variable or parameter and is classified as a variable. </list_item><list_item> Otherwise, for each type T, starting with the immediately enclosing class, struct, or enumeration declaration and continuing with each enclosing outer class or struct declaration (if any), if a member lookup of the <non_terminal where="14.5.2">simple-name</non_terminal> in T produces a match: </list_item><list><list_item> If T is the immediately enclosing class or struct type and the lookup identifies one or more methods, the result is a method group with an associated instance expression of this. </list_item><list_item> If T is the immediately enclosing class or struct type, if the lookup identifies an instance member, and if the reference occurs within the block of an instance constructor, an instance method, or an instance accessor, the result is the same as a member access (<hyperlink>14.5.4</hyperlink>) of the form this.E, where E is the <non_terminal where="14.5.2">simple-name</non_terminal>. </list_item><list_item> Otherwise, the result is the same as a member access (<hyperlink>14.5.4</hyperlink>) of the form T.E, where E is the <non_terminal where="14.5.2">simple-name</non_terminal>. In this case, it is a compile-time error for the <non_terminal where="14.5.2">simple-name</non_terminal> to refer to an instance member. </list_item></list><list_item> Otherwise, starting with the namespace in which the <non_terminal where="14.5.2">simple-name</non_terminal> occurs, continuing with each enclosing namespace (if any), and ending with the global namespace, the following steps are evaluated until an entity is located: </list_item><list><list_item> If the namespace contains a namespace member with the given name, then the <non_terminal where="14.5.2">simple-name</non_terminal> refers to that member and, depending on the member, is classified as a namespace or a type. </list_item><list_item> Otherwise, if the namespace has a corresponding namespace declaration enclosing the location where the <non_terminal where="14.5.2">simple-name</non_terminal> occurs, then: </list_item><list><list_item> If the namespace declaration contains a <non_terminal where="16.3.1">using-alias-directive</non_terminal> that associates the given name with an imported namespace or type, then the <non_terminal where="14.5.2">simple-name</non_terminal> refers to that namespace or type. </list_item><list_item> Otherwise, if the namespaces imported by the <non_terminal where="16.3.2">using-namespace-directive</non_terminal>s of the namespace declaration contain exactly one type with the given name, then the <non_terminal where="14.5.2">simple-name</non_terminal> refers to that type. </list_item><list_item> Otherwise, if the namespaces imported by the <non_terminal where="16.3.2">using-namespace-directive</non_terminal>s of the namespace declaration contain more than one type with the given name, then the <non_terminal where="14.5.2">simple-name</non_terminal> is ambiguous and a compile-time error occurs. </list_item></list></list><list_item> Otherwise, the name given by the <non_terminal where="14.5.2">simple-name</non_terminal> is undefined and a compile-time error occurs. </list_item></list></paragraph>
</clause>
