@@ -54,7 +54,7 @@ class ElimRepeated extends MiniPhase with InfoTransformer { thisPhase =>
54
54
|""" .stripMargin,
55
55
sym.sourcePos)
56
56
else
57
- addVarArgsForwarder(sym, isJavaOverride)
57
+ addVarArgsForwarder(sym, isJavaOverride, hasAnnotation )
58
58
else if hasAnnotation
59
59
report.error(" A method without repeated parameters cannot be annotated with @varargs" , sym.sourcePos)
60
60
end
@@ -260,7 +260,7 @@ class ElimRepeated extends MiniPhase with InfoTransformer { thisPhase =>
260
260
* The solution is to add a method that converts its argument from `Array[? <: T]` to `Seq[T]` and
261
261
* forwards it to the original method.
262
262
*/
263
- private def addVarArgsForwarder (original : Symbol , isBridge : Boolean )(using Context ): Unit =
263
+ private def addVarArgsForwarder (original : Symbol , isBridge : Boolean , hasAnnotation : Boolean )(using Context ): Unit =
264
264
val owner = original.owner
265
265
if ! owner.isClass then
266
266
report.error(" inner methods cannot be annotated with @varargs" , original.sourcePos)
@@ -289,7 +289,11 @@ class ElimRepeated extends MiniPhase with InfoTransformer { thisPhase =>
289
289
}
290
290
conflict match
291
291
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)
293
297
case None =>
294
298
decls.enter(forwarder.enteredAfter(thisPhase))
295
299
0 commit comments