Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Scala 2.13 compiler flags
val scalacOptions ++= Seq(
"utf-8", // Specify character encoding used by source files.
"-deprecation", // Emit warning and location for usages of deprecated APIs.
"-explaintypes", // Explain type errors in more detail.
"-feature", // Emit warning and location for usages of features that should be imported explicitly.
"-language:existentials", // Existential types (besides wildcard types) can be written and inferred
"-language:experimental.macros", // Allow macro definition (besides implementation and application)
"-language:higherKinds", // Allow higher-kinded types
"-language:implicitConversions", // Allow definition of implicit functions called views
"-language:postfixOps", // Allow post fix ops
"-unchecked", // Enable additional warnings where generated code depends on assumptions.
"-Xcheckinit", // Wrap field accessors to throw an exception on uninitialized access.
"-Xfatal-warnings", // Fail the compilation if there are any warnings.
"-Xlint:-serial", // Enable all except for serial. see scalac -Xlint:help for more
"-Ybackend-parallelism", java.lang.Runtime.getRuntime.availableProcessors().toString, // Scala 2.12.5 compiler flag to run some compilation tasks in parallel
"-Ywarn-dead-code", // Warn when dead code is identified.
"-Ywarn-extra-implicit", // Warn when more than one implicit parameter section is defined.
"-Ywarn-numeric-widen", // Warn when numerics are widened.
"-Ywarn-value-discard" // Warn when non-Unit expression results are unused.
// Stats and scalac-profiling - see
// uncomment the bloop plugin in project/plugins.sbt
// ,"-Ystatistics:typer", "-Ybackend-parallelism", "1" // stats
// ,"-Ycache-plugin-class-loader:last-modified"
// ,"-Ycache-plugin-class-loader:last-modified"
// ,"-Xplugin:/Users/USER/Library/Caches/Coursier/v1/https/"
// ,"-P:scalac-profiling:no-profiledb"
// ,"-P:scalac-profiling:show-profiles"
// ,"-P:scalac-profiling:sourceroot:PATH_TO_PROJECT_ROOT
Copy link

channingwalton commented Sep 27, 2019

I had both -Xlint:unused and all the -Ywarn-unused but you don't need both. See


Copy link

vn971 commented Jan 13, 2020


Nice, comparing to many other online article that suggests using a hardcoded number like 4 or 8.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment