Upgrade to Scala

0

I just upgraded to Scala latest version 2.13.2, now I resolved all dependencies. Inside IntelliJ sbt refresh is working fine, but when I build the project I am getting this error:

Error: scalac: 'by-name-right-associative' is not a valid choice for '-Xlint'
Error: scalac: 'nullary-override' is not a valid choice for '-Xlint'
Error: scalar: 'unsound-match' is not a valid choice for '-Xlint'
Error: scala: bad option: '-Yno-adapted-args'

Not, sure what to do about it, I tried checking everywhere, but I am not able to resolve it. Can someone please help.

It seems that your project configures some flags for the compiler which are no longer valid with this version of Scala. There should be a scalacOptions key in your SBT configuration (build.sbt typically) which sets those flags.

You can check this documentation page to see the valid compiler flags for the current Scala version : https://docs.scala-lang.org/overviews/compiler-options/index.html ; however it still mentions -Xlint:nullary-override so maybe it isn’t entirely up to date? Dropping this flag is mentioned in the release notes for Scala 2.13.3 however : https://github.com/scala/scala/releases/tag/v2.13.3 (which makes it weird that you have an error for this specific flag with Scala 2.13.2, bu I haven’t had time to investigate further).

I am not sure where its getting set, I don’t have any scalacOptions in any of my build files.

Finally this helped,

scalacOptions --= Seq(
  "-Xlint:by-name-right-associative",
  "-Xlint:nullary-override",
  "-Xlint:unsound-match",
  "-Yno-adapted-args"
)

Are you using any sbt plugins?

Are you building from SBT or from within IntelliJ? In the latter case, I would look for IntelliJ settings that might translate into compiler flags.

Also how did you upgrade Scala? Did you change the Scala version setting your SBT build project?

this was also asked at https://stackoverflow.com/questions/63051751/upgrading-to-scala-2-13-giving-scalaoptions-error

(when asking the same question in multiple places on the net, it’s polite to crosslink like this, so people don’t waste their time helping you in one place, if you already got helped in the other place)