In Java 8 compiler, what is nameexpr field in JCVariableDecl for

The code is checking for a receiver parameter, which looks like this:

public class SomeClass {
    
    public void foo(SomeClass this) {
        //          ^^^^^^^^^^^^^^
    }
}

In the grammar production rules of the spec, it is listed as:

FormalParameterList:
ReceiverParameter 
FormalParameters , LastFormalParameter 
LastFormalParameter

FormalParameters:
FormalParameter {, FormalParameter} 
ReceiverParameter {, FormalParameter}

ReceiverParameter:
{Annotation} UnannType [Identifier .] this

It's a parameter that has the name of "this", or NameOfOuterClass.this if in an inner class constructor. this is not an identifier, so this is why it is checking for pn.hasTag(Tag.IDENT).

If you have not heard of receiver parameters before, it's basically a "an optional syntactic device that exists solely to allow the type of the represented object to be denoted in source code, so that the type may be annotated," and "it is never bound to any value passed as an argument in a method invocation expression or qualified class instance creation expression, and it has no effect whatsoever at run time" as the language spec puts it.

Since it has almost the same structure as a variable declarator, I guess they decided to also use JCVariableDecl to represent it.