File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
compiler/src/dotty/tools/dotc/transform Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -261,7 +261,12 @@ class ElimRepeated extends MiniPhase with InfoTransformer { thisPhase =>
261261 * forwards it to the original method.
262262 */
263263 private def addVarArgsForwarder (original : Symbol , isBridge : Boolean )(using Context ): Unit =
264- val classInfo = original.owner.info
264+ val owner = original.owner
265+ if ! owner.isClass then
266+ report.error(" inner methods cannot be annotated with @varargs" , original.sourcePos)
267+ return
268+
269+ val classInfo = owner.info
265270 val decls = classInfo.decls.cloneScope
266271
267272 // For simplicity we always set the varargs flag,
Original file line number Diff line number Diff line change @@ -25,4 +25,10 @@ object Test {
2525 @ varargs def v6 : Int = 1 // error
2626 @ varargs def v7 (i : Int * )() = i.sum // error
2727
28+ def f () =
29+ @ varargs def inner (s : String * ) = () // error
30+ inner(" wrong" )
31+
2832}
33+
34+ @ varargs def topLevel (s : String * ) = () // ok
You can’t perform that action at this time.
0 commit comments