@@ -329,29 +329,43 @@ object JavaParsers {
329329 }
330330
331331 def annotations (): List [Tree ] = {
332- // var annots = new ListBuffer[Tree]
332+ var annots = new ListBuffer [Tree ]
333333 while (in.token == AT ) {
334334 in.nextToken()
335- annotation()
335+ annotation() match {
336+ case Some (anno) => annots += anno
337+ case _ =>
338+ }
336339 }
337- List () // don't pass on annotations for now
340+ annots.toList
338341 }
339342
340343 /** Annotation ::= TypeName [`(` AnnotationArgument {`,` AnnotationArgument} `)`]
341344 */
342- def annotation (): Unit = {
343- qualId()
344- if (in.token == LPAREN ) { skipAhead(); accept(RPAREN ) }
345- else if (in.token == LBRACE ) { skipAhead(); accept(RBRACE ) }
345+ def annotation (): Option [Tree ] = {
346+ val id = convertToTypeId(qualId())
347+ // only parse annotations without arguments
348+ if (in.token == LPAREN && in.lookaheadToken != RPAREN ) {
349+ skipAhead()
350+ accept(RPAREN )
351+ None
352+ }
353+ else {
354+ if (in.token == LPAREN ) {
355+ in.nextToken()
356+ accept(RPAREN )
357+ }
358+ Some (ensureApplied(Select (New (id), nme.CONSTRUCTOR )))
359+ }
346360 }
347361
348362 def modifiers (inInterface : Boolean ): Modifiers = {
349363 var flags : FlagSet = Flags .JavaDefined
350364 // assumed true unless we see public/private/protected
351365 var isPackageAccess = true
352- var annots : List [Tree ] = Nil
366+ var annots = new ListBuffer [Tree ]
353367 def addAnnot (sym : ClassSymbol ) =
354- annots : += atSpan(in.offset) {
368+ annots += atSpan(in.offset) {
355369 in.nextToken()
356370 New (TypeTree (sym.typeRef))
357371 }
@@ -360,7 +374,10 @@ object JavaParsers {
360374 in.token match {
361375 case AT if (in.lookaheadToken != INTERFACE ) =>
362376 in.nextToken()
363- annotation()
377+ annotation() match {
378+ case Some (anno) => annots += anno
379+ case _ =>
380+ }
364381 case PUBLIC =>
365382 isPackageAccess = false
366383 in.nextToken()
@@ -396,7 +413,7 @@ object JavaParsers {
396413 if (isPackageAccess && ! inInterface) thisPackageName
397414 else tpnme.EMPTY
398415
399- return Modifiers (flags, privateWithin) withAnnotations annots
416+ return Modifiers (flags, privateWithin) withAnnotations annots.toList
400417 }
401418 assert(false , " should not be here" )
402419 throw new RuntimeException
0 commit comments