@@ -1318,9 +1318,9 @@ object Parsers {
1318
1318
* | `(' [ExprsInParens `,'] PostfixExpr `:' `_' `*' ')'
1319
1319
*
1320
1320
* Special treatment for arguments of primary class constructor
1321
- * annotations. Empty argument lists `(` `)` get represented
1322
- * as `List(ParamNotArg)` instead of `Nil`, indicating that the
1323
- * token sequence should be interpreted as an empty parameter clause
1321
+ * annotations. All empty argument lists `(` `)` follwoing the first
1322
+ * get represented as `List(ParamNotArg)` instead of `Nil`, indicating that
1323
+ * the token sequence should be interpreted as an empty parameter clause
1324
1324
* instead. `ParamNotArg` can also be produced when parsing the first
1325
1325
* argument (see `classConstrAnnotExpr`).
1326
1326
*
@@ -1329,13 +1329,15 @@ object Parsers {
1329
1329
* contains the tokens that need to be replayed to parse the parameter clause.
1330
1330
* Otherwise, `lookaheadTokens` is empty.
1331
1331
*/
1332
- def parArgumentExprs (): List [Tree ] = {
1332
+ def parArgumentExprs (first : Boolean = false ): List [Tree ] = {
1333
1333
if (inClassConstrAnnots) {
1334
1334
assert(lookaheadTokens.isEmpty)
1335
1335
saveLookahead()
1336
1336
accept(LPAREN )
1337
1337
val args =
1338
- if (in.token == RPAREN ) ParamNotArg :: Nil
1338
+ if (in.token == RPAREN )
1339
+ if (first) Nil // first () counts as annotation argument
1340
+ else ParamNotArg :: Nil
1339
1341
else {
1340
1342
openParens.change(LPAREN , + 1 )
1341
1343
try commaSeparated(argumentExpr)
@@ -1377,8 +1379,8 @@ object Parsers {
1377
1379
* Otherwise parse as normal.
1378
1380
*/
1379
1381
def classConstrAnnotExpr () = {
1380
- saveLookahead()
1381
1382
if (in.token == IDENTIFIER ) {
1383
+ saveLookahead()
1382
1384
postfixExpr() match {
1383
1385
case Ident (_) if in.token == COLON => ParamNotArg
1384
1386
case t => expr1Rest(t, Location .InParens )
@@ -1404,9 +1406,9 @@ object Parsers {
1404
1406
*/
1405
1407
def parArgumentExprss (fn : Tree ): Tree =
1406
1408
if (in.token == LPAREN ) {
1407
- val first = parArgumentExprs()
1408
- if (inClassConstrAnnots && first == ParamNotArg :: Nil ) fn
1409
- else parArgumentExprss(Apply (fn, first ))
1409
+ val args = parArgumentExprs(first = ! fn. isInstanceOf [ Trees . Apply [_]] )
1410
+ if (inClassConstrAnnots && args == ParamNotArg :: Nil ) fn
1411
+ else parArgumentExprss(Apply (fn, args ))
1410
1412
}
1411
1413
else fn
1412
1414
0 commit comments