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 =>
261
261
* forwards it to the original method.
262
262
*/
263
263
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
265
270
val decls = classInfo.decls.cloneScope
266
271
267
272
// For simplicity we always set the varargs flag,
Original file line number Diff line number Diff line change @@ -25,4 +25,10 @@ object Test {
25
25
@ varargs def v6 : Int = 1 // error
26
26
@ varargs def v7 (i : Int * )() = i.sum // error
27
27
28
+ def f () =
29
+ @ varargs def inner (s : String * ) = () // error
30
+ inner(" wrong" )
31
+
28
32
}
33
+
34
+ @ varargs def topLevel (s : String * ) = () // ok
You can’t perform that action at this time.
0 commit comments