@@ -359,19 +359,6 @@ object JavaParsers {
359359 * but instead we skip entire annotation silently.
360360 */
361361 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-
375362 def classOrId (): Tree =
376363 val id = qualId()
377364 if in.lookaheadToken == CLASS then
@@ -398,17 +385,17 @@ object JavaParsers {
398385 }
399386
400387 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+ }
412399 }
413400 if in.token == COMMA || in.token == RBRACE || in.token == RPAREN then
414401 tree
@@ -716,11 +703,7 @@ object JavaParsers {
716703
717704 in.nextToken() // EQUALS
718705 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)
724707 }
725708 else tpt1
726709 }
@@ -976,7 +959,11 @@ object JavaParsers {
976959 case _ => in.nextToken(); syntaxError(" illegal start of type declaration" , skipIt = true ); List (errorTypeTree)
977960 }
978961
979- def tryLiteral (negate : Boolean = false ): Option [Constant ] = {
962+ def tryConstant : Option [Constant ] = {
963+ val negate = in.token match {
964+ case MINUS | BANG => in.nextToken(); true
965+ case _ => false
966+ }
980967 val l = in.token match {
981968 case TRUE => ! negate
982969 case FALSE => negate
0 commit comments