Scala 2.13.2 and 2.12.13 introduced the -Wconf
compiler flag to globally configure reporting of warnings, and the @nowarn
annotation to locally suppress them. Having more control over compiler warnings makes them a lot more valuable:
- In projects where the build log shows a lot of of warnings that are mostly ignored, new helpful warnings can easily go undetected. The new functionality can be used to clean up the build log with manageable efforts and potentially enable fatal warning (
-Werror
in 2.13,-Xfatal-warnings
in 2.12). This has happened for example in Scala compiler and standard library projects in the past few months. - Projects that already use fatal warnings get better utilities to work around corner cases where a warning cannot be avoided. This can allow further
-Xlint
checks to be enabled.
In this post we go through the mechanics of configuring warnigns and also look at the new @nowarn
annotation.