1

I'm using varargs like below in my code base.

 def acceptVarargs[S](s: S*): Unit = {}
 def toVarArgs[T](s: Seq[T]) = acceptVarargs(s: _*)

I'm using autofix plugin in my sbt project.

I'm following the steps here to run the scalafix command.

When I run the command sbt> scalafixAll dependency:RenameDeprecatedPackage@org.scalatest:autofix:3.0.8-1 I get below Error.

[error] /Users/rajkumar.natarajan/Documents/Coding/misc/varargs-scalafix-error/src/main/scala/Utils.scala:3: error: repeated argument not allowed here [error] def toVarArgs[T](s: Seq[T]) = acceptVarargs(s: _*) [error] ^ [error] at scala.meta.internal.parsers.Reporter.syntaxError(Reporter.scala:16) [error] at scala.meta.internal.parsers.Reporter.syntaxError$(Reporter.scala:16) [error] at scala.meta.internal.parsers.Reporter$$anon$1.syntaxError(Reporter.scala:22) [error] at scala.meta.internal.parsers.Reporter.syntaxError(Reporter.scala:17) [error] at scala.meta.internal.parsers.Reporter.syntaxError$(Reporter.scala:17)

The complete error stack trace is here

What is wrong in my codebase with varargs? How can I fix this error?

The project in github here

Other details -

sbt version - 1.5.2 scala version - 2.12.10 java version - 11.0.10-zulu

user51
  • 8,843
  • 21
  • 79
  • 158
  • According to the compiler error, the actual code is `def toVarArgs[T](s: Seq[T]) = s: _*`, not `def toVarArgs[T](s: Seq[T]) = acceptVarargs(s: _*)`. Is it possible that you didn't save changes to the file before running `scalafixAll`? – Michał Pawlicki May 26 '21 at 17:45
  • @MichałPawlicki - It happens for both. Anyhow I fixed the error in question. – user51 May 26 '21 at 17:48

0 Answers0