Given that Scala 2.13 has just landed, there are a bunch of new flags and options available to the compiler. Below is a full list of options to choose from.

Standard Options

  • -Dproperty=value Pass -Dproperty=value directly to the runtime system.
  • -J<flag> Pass <flag> directly to the runtime system.
  • -P:<plugin>:<opt> Pass an option to a plugin
  • -V Print a synopsis of verbose options.
  • -W Print a synopsis of warning options.
  • -Werror Fail the compilation if there are any warnings.
  • -X Print a synopsis of advanced options.
  • -Y Print a synopsis of private options.
  • -bootclasspath <path> Override location of bootstrap class files.
  • -classpath <path> Specify where to find user class files.
  • -d <directory|jar> destination for generated classfiles.
  • -dependencyfile <file> Set dependency tracking file.
  • -deprecation Emit warning and location for usages of deprecated APIs.
  • -encoding <encoding> Specify character encoding used by source files.
  • -explaintypes Explain type errors in more detail.
  • -extdirs <path> Override location of installed extensions.
  • -feature Emit warning and location for usages of features that should be imported explicitly.
  • -g:<level> Set level of generated debugging info. (none,source,line,[vars],notailcalls)
  • -help Print a synopsis of standard options
  • -javabootclasspath <path> Override java boot classpath.
  • -javaextdirs <path> Override java extdirs classpath.
  • -language:<features> Enable or disable language features
  • -no-specialization Ignore @specialize annotations.
  • -nobootcp Do not use the boot classpath for the scala jars.
  • -nowarn Generate no warnings.
  • -opt:<optimizations> Enable optimizations
  • -opt-inline-from:<patterns> Patterns for classfile names from which to allow inlining, help for details.
  • -opt-warnings:<warnings> Enable optimizer warnings
  • -print Print program with Scala-specific features removed.
  • -release <release> Compile for a specific version of the Java platform. Supported targets: 6, 7, 8, 9
  • -sourcepath <path> Specify location(s) of source files.
  • -target:<target> Target platform for object files. All JVM 1.5 - 1.7 targets are deprecated. (jvm-1.5,jvm-1.6,jvm-1.7,[jvm-1.8])
  • -toolcp <path> Add to the runner classpath.
  • -unchecked Enable additional warnings where generated code depends on assumptions.
  • -uniqid Uniquely tag all identifiers in debugging output.
  • -usejavacp Utilize the java.class.path in classpath resolution.
  • -usemanifestcp Utilize the manifest in classpath resolution.
  • -verbose Output messages about what the compiler is doing.
  • -version Print product version and exit.
  • @<file> A text file containing compiler arguments (options and source files)

Deprecated settings:

  • -optimize Enables optimizations. deprecated: Since 2.12, enables -opt:l:inline -opt-inline-from:**. See -opt:help.

Verbose Options (-V)

  • -Vbrowse:<phases> Browse the abstract syntax tree after <phases>
  • -Vclasspath Output information about what classpath is being applied.
  • -Vdebug Increase the quantity of debugging output.
  • -Vdoc Trace scaladoc activity.
  • -Vfree-terms Print a message when reification creates a free term.
  • -Vfree-types Print a message when reification resorts to generating a free type.
  • -Vhot-statistics Enable -Vstatistics to also print hot statistics.
  • -Vide Generate, validate and output trees using the interactive compiler.
  • -Vimplicit-conversions Print a message whenever an implicit conversion is inserted.
  • -Vimplicits Show more detail on why some implicits are not applicable.
  • -Vinline <package/Class.method> Print a summary of inliner activity; _ to print all, prefix match to select.
  • -Vissue Print stack traces when a context issues an error.
  • -Vlog:<phases> Log operations during <phases>
  • -Vmacro Trace macro activities: compilation, generation of synthetics, classloading, expansion, exceptions.
  • -Vmacro-lite Trace macro activities with less output.
  • -Vopt <package/Class.method> Trace the optimizer progress for methods; _ to print all, prefix match to select.
  • -Vpatmat Trace pattern matching translation.
  • -Vphases Print a synopsis of compiler phases.
  • -Vpos Trace position validation.
  • -Vprint:<phases> Print out program after <phases>
  • -Vprint-args <file> Print all compiler arguments to the specified location. Use - to echo to the reporter.
  • -Vprint-pos Print tree positions, as offsets.
  • -Vprint-types Print tree types (debugging option).
  • -Vquasiquote Trace quasiquotations.
  • -Vreflective-calls Print a message when a reflective method call is generated
  • -Vreify Trace reification.
  • -Vshow:<phases> (Requires -Xshow-class or -Xshow-object) Show after <phases>
  • -Vshow-class <class> Show internal representation of class.
  • -Vshow-member-pos <output style> Show start and end positions of members (implies -Yrangepos)
  • -Vshow-object <object> Show internal representation of object.
  • -Vshow-symkinds Print abbreviated symbol kinds next to symbol names.
  • -Vshow-symowners Print owner identifiers next to symbol names.
  • -Vstatistics[:phases] Print compiler statistics for specific phases <phases> (default: parser,typer,patmat,erasure,cleanup,jvm)
  • -Vsymbols Print the AST symbol hierarchy after each phase.
  • -Vtyper Trace type assignments.
  • Note:
    • Boolean settings are false unless set: -Xdev -Xcheck-init:true -Xprompt:false
    • Multi-valued settings are comma-separated: -Xlint:infer-any,unused,-missing-interpolator
    • Phases are a list of names, ids, or ranges of ids: -Xprint:parser,typer,5-10 -Ylog:-4_
    • Use _ to enable all: -language:_ -Xprint:_

Warning Options (-W)

  • -Wdead-code Warn when dead code is identified.
  • -Wextra-implicit Warn when more than one implicit parameter section is defined.
  • -Wmacros:<mode> Enable lint warnings on macro expansions. Default: before, help to list choices.
  • -Wnumeric-widen Warn when numerics are widened.
  • -Woctal-literal Warn on obsolete octal syntax.
  • -Wself-implicit Warn when an implicit resolves to an enclosing self-definition.
  • -Wunused:imports Warn if an import selector is not referenced.
  • -Wunused:patvars Warn if a variable bound in a pattern is unused.
  • -Wunused:privates Warn if a private member is unused.
  • -Wunused:locals Warn if a local definition is unused.
  • -Wunused:explicits Warn if an explicit parameter is unused.
  • -Wunused:implicits Warn if an implicit parameter is unused.
  • -Wunused:params Enable -Wunused:explicits,implicits.
  • -Wunused:linted -Xlint:unused.
  • -Wvalue-discard Warn when non-Unit expression results are unused.
  • -Xlint:adapted-args Warn if an argument list is modified to match the receiver.
  • -Xlint:nullary-unit Warn when nullary methods return Unit.
  • -Xlint:inaccessible Warn about inaccessible types in method signatures.
  • -Xlint:nullary-override Warn when non-nullary def f()' overrides nullarydef f’.
  • -Xlint:infer-any Warn when a type argument is inferred to be Any.
  • -Xlint:missing-interpolator A string literal appears to be missing an interpolator id.
  • -Xlint:doc-detached A Scaladoc comment appears to be detached from its element.
  • -Xlint:private-shadow A private field (or class parameter) shadows a superclass field.
  • -Xlint:type-parameter-shadow A local type parameter shadows a type already in scope.
  • -Xlint:poly-implicit-overload Parameterized overloaded implicit methods are not visible as view bounds.
  • -Xlint:option-implicit Option.apply used implicit view.
  • -Xlint:delayedinit-select Selecting member of DelayedInit.
  • -Xlint:package-object-classes Class or object defined in package object.
  • -Xlint:stars-align Pattern sequence wildcard must align with sequence component.
  • -Xlint:constant Evaluation of a constant arithmetic expression results in an error.
  • -Xlint:unused Enable -Ywarn-unused:imports,privates,locals,implicits.
  • -Xlint:nonlocal-return A return statement used an exception for flow control.
  • -Xlint:implicit-not-found Check @implicitNotFound and @implicitAmbiguous messages.
  • -Xlint:serial @SerialVersionUID on traits and non-serializable classes.
  • -Xlint:valpattern Enable pattern checks in val definitions.
  • -Xlint:eta-zero Warn on eta-expansion (rather than auto-application) of zero-ary method.
  • -Xlint:eta-sam Warn on eta-expansion to meet a Java-defined functional interface that is not explicitly annotated with @FunctionalInterface.
  • -Xlint:deprecation Enable linted deprecations.

Advanced Options (-X)

  • -Xcheckinit Wrap field accessors to throw an exception on uninitialized access.
  • -Xdev Indicates user is a developer - issue warnings about anything which seems amiss
  • -Xdisable-assertions Generate no assertions or assumptions.
  • -Xelide-below <n> Calls to @elidable methods are omitted if method priority is lower than argument
  • -Xgenerate-phase-graph <file> Generate the phase graphs (outputs .dot files) to fileX.dot.
  • -Xlint:<warnings> Enable recommended warnings
  • -Xmacro-settings:<option> Custom settings for macros.
  • -Xmain-class <path> Class for manifest’s Main-Class entry (only useful with -d <jar>)
  • -Xmaxerrs <n> Maximum errors to print
  • -Xmaxwarns <n> Maximum warnings to print
  • -Xmigration:<version> Warn about constructs whose behavior may have changed since version.
  • -Xmixin-force-forwarders:<mode> Generate forwarder methods in classes inhering concrete methods from traits. Default: true, help to list choices.
  • -Xno-forwarders Do not generate static forwarders in mirror classes.
  • -Xno-patmat-analysis Don’t perform exhaustivity/unreachability analysis. Also, ignore @switch annotation.
  • -Xno-uescape Disable handling of nicode escapes.
  • -Xnojline Do not use JLine for editing.
  • -Xplugin:<paths> Load a plugin from each classpath.
  • -Xplugin-disable:<plugin> Disable plugins by name.
  • -Xplugin-list Print a synopsis of loaded plugins.
  • -Xplugin-require:<plugin> Abort if a named plugin is not loaded.
  • -Xpluginsdir <path> Path to search for plugin archives.
  • -Xprompt Display a prompt after each error (debugging option).
  • -Xreporter <classname> Specify a custom reporter for compiler messages.
  • -Xresident Compiler stays resident: read source filenames from standard input.
  • -Xscript <object> Treat the source file as a script and wrap it in a main method.
  • -Xsource:<version> Treat compiler input as Scala source for the specified version, see scala/bug#8126.
  • -Xsource-reader <classname> Specify a custom method for reading source files.
  • -Xverify Verify generic signatures in generated bytecode.
  • -Xxml:<propertys> Configure XML parsing.

Private Options (-Y)

  • -Ybackend-parallelism <n> maximum worker threads for backend
  • -Ybackend-worker-queue <n> backend threads worker queue size
  • -Ybreak-cycles Attempt to break cycles encountered during typing
  • -Ycache-macro-class-loader:<policy> Policy for caching class loaders for macros that are dynamically loaded. Default: none, help to list choices.
  • -Ycache-plugin-class-loader:<policy> Policy for caching class loaders for compiler plugins that are dynamically loaded. Default: none, help to list choices.
  • -Ycheck:<phases> Check the tree at the end of <phases>
  • -Ycompact-trees Use compact tree printer when displaying trees.
  • -Ydelambdafy:<strategy> Strategy used for translating lambdas into JVM code. (inline,[method])
  • -Ydump-classes <dir> Dump the generated bytecode to .class files (useful for reflective compilation that utilizes in-memory classloaders).
  • -Ygen-asmp <dir> Generate a parallel output directory of .asmp files (ie ASM Textifier output).
  • -Yimports:<import> Custom root imports, default is java.lang,scala,scala.Predef.
  • -Yjar-compression-level <n> compression level to use when writing jar files
  • -Ymacro-annotations Enable support for macro annotations, formerly in macro paradise.
  • -Ymacro-classpath <path> The classpath used to reflectively load macro implementations, default is the compilation classpath.
  • -Ymacro-expand:<policy> Control expansion of macros, useful for scaladoc and presentation compiler. ([normal],none,discard)
  • -Ymacro-global-fresh-names Should fresh names in macros be unique across all compilation units
  • -Yno-completion Disable tab-completion in the REPL.
  • -Yno-flat-classpath-cache Do not cache flat classpath representation of classpath elements from jars across compiler instances.
  • -Yno-generic-signatures Suppress generation of generic signatures for Java.
  • -Yno-imports Compile without importing scala., java.lang., or Predef.
  • -Yno-predef Compile without importing Predef.
  • -Yopt-inline-heuristics:<strategy> Set the heuristics for inlining decisions. (at-inline-annotated,everything,[default])
  • -Ypatmat-exhaust-depth <n> off
  • -Ypresentation-any-thread Allow use of the presentation compiler from any thread
  • -Ypresentation-debug Enable debugging output for the presentation compiler.
  • -Ypresentation-delay <n> Wait number of ms after typing before starting typechecking
  • -Ypresentation-log <file> Log presentation compiler events into file
  • -Ypresentation-replay <file> Replay presentation compiler events from file
  • -Ypresentation-strict Do not report type errors in sources with syntax errors.
  • -Ypresentation-verbose Print information about presentation compiler tasks.
  • -Yprint-trees:<style> How to print trees when -Xprint is enabled. ([text],compact,format,text+format)
  • -Yprofile-destination <file> Profiling output - specify a file or - for console.
  • -Yprofile-enabled Enable profiling.
  • -Yprofile-external-tool[:phases] Enable profiling for a phase using an external tool hook. Generally only useful for a single phase <phases> (default: typer)
  • -Yprofile-run-gc[:phases] Run a GC between phases - this allows heap size to be accurate at the expense of more time. Specify a list of phases, or all <phases> (default: _)
  • -Yprofile-trace <file> Capture trace of compilation in Chrome Trace format
  • -Yrangepos Use range positions for syntax trees.
  • -Yrecursion <n> Set recursion depth used when locking symbols.
  • -Yreify-copypaste Dump the reified trees in copypasteable representation.
  • -Yrepl-class-based Use classes to wrap REPL snippets instead of objects
  • -Yrepl-outdir <path> Write repl-generated classfiles to given output directory (use “” to generate a temporary dir)
  • -Yresolve-term-conflict:<strategy> Resolve term conflicts. (package,object,[error])
  • -Yscriptrunner <classname> Specify a scala.tools.nsc.ScriptRunner (default, resident, shutdown, or a class name).
  • -Yskip:<phases> Skip <phases>
  • -Ystop-after:<phases> Stop after <phases>
  • -Ystop-before:<phases> Stop before <phases>
  • -Yvalidate-pos:<phases> Validate positions after the given phases (implies -Yrangepos) <phases>
  • Note:
    • Boolean settings are false unless set: -Xdev -Xcheck-init:true -Xprompt:false
    • Multi-valued settings are comma-separated: -Xlint:infer-any,unused,-missing-interpolator
    • Phases are a list of names, ids, or ranges of ids: -Xprint:parser,typer,5-10 -Ylog:-4
    • Use _ to enable all: -language:_ -Xprint:_