@@ -54,7 +54,7 @@ class ElimRepeated extends MiniPhase with InfoTransformer { thisPhase =>
5454 |""" .stripMargin,
5555 sym.sourcePos)
5656 else
57- addVarArgsForwarder(sym, isJavaOverride)
57+ addVarArgsForwarder(sym, isJavaOverride, hasAnnotation )
5858 else if hasAnnotation
5959 report.error(" A method without repeated parameters cannot be annotated with @varargs" , sym.sourcePos)
6060 end
@@ -260,7 +260,7 @@ class ElimRepeated extends MiniPhase with InfoTransformer { thisPhase =>
260260 * The solution is to add a method that converts its argument from `Array[? <: T]` to `Seq[T]` and
261261 * forwards it to the original method.
262262 */
263- private def addVarArgsForwarder (original : Symbol , isBridge : Boolean )(using Context ): Unit =
263+ private def addVarArgsForwarder (original : Symbol , isBridge : Boolean , hasAnnotation : Boolean )(using Context ): Unit =
264264 val owner = original.owner
265265 if ! owner.isClass then
266266 report.error(" inner methods cannot be annotated with @varargs" , original.sourcePos)
@@ -289,7 +289,11 @@ class ElimRepeated extends MiniPhase with InfoTransformer { thisPhase =>
289289 }
290290 conflict match
291291 case Some (conflict) =>
292- report.error(s " @varargs produces a forwarder method that conflicts with ${conflict.showDcl}" , original.sourcePos)
292+ val src =
293+ if hasAnnotation then " @varargs"
294+ else if isBridge then " overriding a java varargs method"
295+ else " @varargs (on overriden method)"
296+ report.error(s " $src produces a forwarder method that conflicts with ${conflict.showDcl}" , original.sourcePos)
293297 case None =>
294298 decls.enter(forwarder.enteredAfter(thisPhase))
295299
0 commit comments