File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
compiler/src/dotty/tools/dotc/transform Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -27,22 +27,23 @@ class RepeatableAnnotations extends MiniPhase:
2727 private def aggregateAnnotations (annotations : Seq [Annotation ])(using Context ): List [Annotation ] =
2828 val annsByType = annotations.groupBy(_.symbol)
2929 annsByType.flatMap {
30- case (_, a :: Nil ) => Some (a)
31- case (sym, anns) =>
30+ case (_, a :: Nil ) => a :: Nil
31+ case (sym, anns) if sym.derivesFrom(defn. ClassfileAnnotationClass ) =>
3232 sym.annotations.find(_ matches defn.JavaRepeatableAnnot ).flatMap(_.argumentConstant(0 )) match
3333 case Some (Constant (containerTpe : Type )) =>
3434 val clashingAnns = annsByType.getOrElse(containerTpe.classSymbol, Nil )
3535 if ! clashingAnns.isEmpty then
3636 // this is the same error javac would raise in this case
3737 val pos = clashingAnns.map(_.tree.srcPos).minBy(_.line)
3838 report.error(" Container must not be present at the same time as the element it contains" , pos)
39- None
39+ Nil
4040 else
4141 val aggregated = JavaSeqLiteral (anns.map(_.tree).toList, TypeTree (sym.typeRef))
42- Some ( Annotation (containerTpe, NamedArg (" value" .toTermName, aggregated)))
42+ Annotation (containerTpe, NamedArg (" value" .toTermName, aggregated)) :: Nil
4343 case _ =>
4444 val pos = anns.map(_.tree.srcPos).sortBy(_.line).apply(1 )
4545 report.error(" Not repeatable annotation repeated" , pos)
46- None
46+ Nil
47+ case (_, anns) => anns
4748 }.toList
4849
You can’t perform that action at this time.
0 commit comments