-
Bug
-
Resolution: Fixed
-
P4
-
8
The JLS8 grammar does not permit a method's FormalParameterList to consist solely of a 'this' receiver parameter, despite examples showing such a method. The grammar demands that a ReceiverParameter is followed by (at least) a LastFormalParameter. It is clearly desirable to add a third alternative to FormalParameterList:
FormalParameterList:
ReceiverParameter /* 1 recv, 0 formals */
FormalParameters , LastFormalParameter /* 1 recv, 1+ formals OR 0 recv, 1+ formals */
LastFormalParameter /* 0 recv, 1 formal */
(No changes needed to ReceiverParameter or FormalParameters or LastFormalParameter.)
The clause "A receiver parameter may appear only in the FormalParameters of an instance method or an inner class's constructor; otherwise, a compile-time error occurs." must mention FormalParameterList rather than FormalParameters.
FormalParameterList:
ReceiverParameter /* 1 recv, 0 formals */
FormalParameters , LastFormalParameter /* 1 recv, 1+ formals OR 0 recv, 1+ formals */
LastFormalParameter /* 0 recv, 1 formal */
(No changes needed to ReceiverParameter or FormalParameters or LastFormalParameter.)
The clause "A receiver parameter may appear only in the FormalParameters of an instance method or an inner class's constructor; otherwise, a compile-time error occurs." must mention FormalParameterList rather than FormalParameters.