@@ -359,19 +359,6 @@ object JavaParsers {
359
359
* but instead we skip entire annotation silently.
360
360
*/
361
361
def annotation (): Option [Tree ] = {
362
- object LiteralT :
363
- def unapply (token : Token ) = Option (token match {
364
- case TRUE => true
365
- case FALSE => false
366
- case CHARLIT => in.name(0 )
367
- case INTLIT => in.intVal(false ).toInt
368
- case LONGLIT => in.intVal(false )
369
- case FLOATLIT => in.floatVal(false ).toFloat
370
- case DOUBLELIT => in.floatVal(false )
371
- case STRINGLIT => in.name.toString
372
- case _ => null
373
- }).map(Constant (_))
374
-
375
362
def classOrId (): Tree =
376
363
val id = qualId()
377
364
if in.lookaheadToken == CLASS then
@@ -398,17 +385,17 @@ object JavaParsers {
398
385
}
399
386
400
387
def argValue (): Option [Tree ] =
401
- val tree = in.token match {
402
- case LiteralT (c) =>
403
- val tree = atSpan(in.offset)(Literal (c))
404
- in.nextToken()
405
- Some (tree)
406
- case AT =>
407
- in.nextToken ()
408
- annotation( )
409
- case IDENTIFIER => Some (classOrId() )
410
- case LBRACE => array()
411
- case _ => None
388
+ val tree = tryConstant match {
389
+ case Some (c) =>
390
+ Some ( atSpan(in.offset)(Literal (c) ))
391
+ case _ => in.token match {
392
+ case AT =>
393
+ in.nextToken()
394
+ annotation ()
395
+ case IDENTIFIER => Some (classOrId() )
396
+ case LBRACE => array( )
397
+ case _ => None
398
+ }
412
399
}
413
400
if in.token == COMMA || in.token == RBRACE || in.token == RPAREN then
414
401
tree
@@ -716,11 +703,7 @@ object JavaParsers {
716
703
717
704
in.nextToken() // EQUALS
718
705
if (mods.is(Flags .JavaStatic ) && mods.is(Flags .Final )) {
719
- val neg = in.token match {
720
- case MINUS | BANG => in.nextToken(); true
721
- case _ => false
722
- }
723
- tryLiteral(neg).map(forConst).getOrElse(tpt1)
706
+ tryConstant.map(forConst).getOrElse(tpt1)
724
707
}
725
708
else tpt1
726
709
}
@@ -1012,7 +995,11 @@ object JavaParsers {
1012
995
case _ => in.nextToken(); syntaxError(" illegal start of type declaration" , skipIt = true ); List (errorTypeTree)
1013
996
}
1014
997
1015
- def tryLiteral (negate : Boolean = false ): Option [Constant ] = {
998
+ def tryConstant : Option [Constant ] = {
999
+ val negate = in.token match {
1000
+ case MINUS | BANG => in.nextToken(); true
1001
+ case _ => false
1002
+ }
1016
1003
val l = in.token match {
1017
1004
case TRUE => ! negate
1018
1005
case FALSE => negate
0 commit comments