Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scala3 equivalent to -Wconf src filter

I have a Play framework application that I'm upgrading to Scala3. While migrating my compile flags I've encountered an issue that I've been unable to resolve by reading the docs.

With the flag combination -Wunused:imports -Werror I get fatal warnings on unused imports. The problem is that in Play framework this gives false positives for the routes file and twirl-templates. In Scala2 i added -Wconf:src=target/.*:s which resolved this issue for me.

When running the same configuration I was alerted to the fact that src is not a valid -Wconf filter in Scala3. The other available filters do not seem to help me in the case.

How can I accomplish the same result in Scala3?

like image 468
Christoffer Avatar asked Oct 22 '25 10:10

Christoffer


1 Answers

Indeed, as stated in the migration guide:

The configuration string for -Wconf will likely require adjustment when migrating to Scala 3, since the configuration syntax and the error messages it matches are different.

Unfortunately from a quick look I cannot find what the configuration syntax is, so I guess the only thing possible right now is to look at the code.

After some digging, it appears that the src filter in -Wconf has not been ported yet, although there is an open PR that adds support for it. With some luck, it could be re-introduced in Scala 3 soon.

Sources:

  • https://github.com/lampepfl/dotty/pull/12857
  • https://github.com/lampepfl/dotty/discussions/17635
  • https://github.com/lampepfl/dotty/pull/18783

While you are waiting for this feature to land, one possibility might be for you to create a separate sbt subproject for those files, using a slightly different compiler configuration.

like image 86
stefanobaghino Avatar answered Oct 24 '25 06:10

stefanobaghino



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!