10.12.2012 Views

The Java Language Specification, Third Edition

The Java Language Specification, Third Edition

The Java Language Specification, Third Edition

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

6.5.2 Reclassification of Contextually Ambiguous Names NAMES<br />

130<br />

◆ Otherwise, if a field of that name is declared in the compilation unit (§7.3)<br />

containing the Identifier by a single-static-import declaration (§7.5.3), or by<br />

a static-import-on-demand declaration (§7.5.4) then the AmbiguousName is<br />

reclassified as an ExpressionName.<br />

◆ Otherwise, if the Identifier appears within the scope (§6.3) of a top level<br />

class (§8) or interface type declaration (§9), a local class declaration (§14.3)<br />

or member type declaration (§8.5, §9.5) with that name, then the AmbiguousName<br />

is reclassified as a TypeName.<br />

◆ Otherwise, if a type of that name is declared in the compilation unit (§7.3)<br />

containing the Identifier, either by a single-type-import declaration (§7.5.1),<br />

or by a type-import-on-demand declaration (§7.5.2), or by a single-staticimport<br />

declaration (§7.5.3), or by a static-import-on-demand declaration<br />

(§7.5.4), then the AmbiguousName is reclassified as a TypeName.<br />

◆ Otherwise, the AmbiguousName is reclassified as a PackageName. A later<br />

step determines whether or not a package of that name actually exists.<br />

• If the AmbiguousName is a qualified name, consisting of a name, a “.”, and an<br />

Identifier, then the name to the left of the “.” is first reclassified, for it is itself<br />

an AmbiguousName. <strong>The</strong>re is then a choice:<br />

◆ If the name to the left of the “.” is reclassified as a PackageName, then if<br />

there is a package whose name is the name to the left of the “.” and that<br />

package contains a declaration of a type whose name is the same as the<br />

Identifier, then this AmbiguousName is reclassified as a TypeName. Otherwise,<br />

this AmbiguousName is reclassified as a PackageName. A later step<br />

determines whether or not a package of that name actually exists.<br />

◆ If the name to the left of the “.” is reclassified as a TypeName, then if the<br />

Identifier is the name of a method or field of the type denoted by TypeName,<br />

this AmbiguousName is reclassified as an ExpressionName. Otherwise, if<br />

the Identifier is the name of a member type of the type denoted by Type-<br />

Name, this AmbiguousName is reclassified as a TypeName. Otherwise, a<br />

compile-time error results.<br />

DRAFT<br />

◆ If the name to the left of the “.” is reclassified as an ExpressionName, then<br />

let T be the type of the expression denoted by ExpressionName. If the Identifier<br />

is the name of a method or field of the type denoted by T, this AmbiguousName<br />

is reclassified as an ExpressionName. Otherwise, if the Identifier<br />

is the name of a member type (§8.5, §9.5) of the type denoted by T, then this<br />

AmbiguousName is reclassified as a TypeName. Otherwise, a compile-time<br />

error results.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!