This doc page is specific to features shipped in Scala 2, which have either been removed in Scala 3 or replaced by an alternative. Unless otherwise stated, all the code examples in this page assume you are using Scala 2.
Introduction
The Scala compiler scalac offers various compiler options, or flags, that change the compiler’s default behavior. Some options just generate more compiler output in the form of diagnostics or warnings, while others change the result of compilation.
The Scala command scala, which runs scripts or compiled code, accepts the same options as the scalac compiler, plus a few more that determine how to run a program.
Options may be specified on the command line to scalac or in the configuration of a build tool or IDE.
The Scala distribution includes a man page. If Scala is installed as a system command, that documentation may be available from man scalac.
How to use compiler options
Use compiler options with scalac
scalac [ <options> ] <source files>
Boolean flags are specified in the usual way:
scalac -Werror -Xlint Hello.scala
Options that require arguments use “colon” syntax:
scalac -Vprint:parser,typer
Options that take just a single argument accept traditional syntax:
scalac -d /tmp
Conventionally, options have a prefix -V if they show “verbose” output;
-W to manage warnings; -X for extended options that modify tool behavior;
-Y for private options with limited support, where Y may suggest forking behavior.
Several options have historical aliases, such as -Xfatal-warnings for -Werror.
In Scala 2, default paths can be listed by running a tool in the distribution:
scala scala.tools.util.PathResolver [ <options> ]
That can help debug errors in options such as --classpath.
Use compiler options with sbt
Here is a typical configuration of the scalacOptions setting in sbt:
scalacOptions ++= Seq( // use ++= to add to existing options
"-encoding", "utf8", // if an option takes an arg, supply it on the same line
"-feature", // then put the next option on a new line for easy editing
"-language:implicitConversions",
"-language:existentials",
"-unchecked",
"-Werror",
"-Xlint", // exploit "trailing comma" syntax so you can add an option without editing this line
) // for "trailing comma", the closing paren must be on the next line
The convention is always to append to the setting with ++= and to supply one option per line.
Normally the last option will have a trailing comma so that git diff is a bit cleaner when options are added.
Standard Settings
A set of standard options that are supported on the current development environment and will be supported in future releases.
-
-Dproperty=value -
Pass -Dproperty=value directly to the runtime system.
-
-J<flag> -
Pass flag directly to the runtime system.
-
-P PLUGIN:OPT1,PLUGIN:OPT2 -
Pass an option to a plugin
-
-V -
Print a synopsis of verbose options.
-
-W -
Print a synopsis of warning options.
-
-Werroror-Xfatal-warnings -
Fail the compilation if there are any warnings.
-
-X -
Print a synopsis of advanced options.
-
-Y -
Print a synopsis of private options.
-
-bootclasspath PATHor--boot-class-path PATH -
Override location of bootstrap class files.
-
-classpath PATHor-cp PATHor--class-path PATH -
Specify where to find user class files.
Default:.
-
-d DIRECTORY|JAR -
destination for generated classfiles.
Default:.
-
-dependencyfile FILEor--dependency-file FILE -
Set dependency tracking file.
Default:.scala_dependencies
-
-deprecationor--deprecation -
Emit warning and location for usages of deprecated APIs.
-
-encoding ENCODINGor--encoding ENCODING -
Specify character encoding used by source files.
Default:UTF-8
-
-explaintypesor--explain-types -
Explain type errors in more detail.
-
-extdirs PATHor--extension-directories PATH -
Override location of installed extensions.
-
-featureor--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)
Default:vars
-
-g:none-g:source-g:line-g:vars-g:notailcalls
-
-helpor--help -
Print a synopsis of standard options
-
-javabootclasspath PATHor--java-boot-class-path PATH -
Override java boot classpath.
Default:
-
-javaextdirs PATHor--java-extension-directories PATH -
Override java extdirs classpath.
-
-language:FEATURE1,FEATURE2or--language:FEATURE1,FEATURE2 -
Enable or disable language features
-
-language:dynamicsAllow direct or indirect subclasses of scala.Dynamic
-language:existentialsExistential types (besides wildcard types) can be written and inferred
-language:higherKindsAllow higher-kinded types
-language:implicitConversionsAllow definition of implicit functions called views
-language:postfixOpsAllow postfix operator notation, such as
1 to 10 toList(not recommended)-language:reflectiveCallsAllow reflective access to members of structural types
-language:experimental.macrosAllow macro definition (besides implementation and application)
-
-no-specializationor--no-specialization -
Ignore @specialize annotations.
-
-nobootcpor--no-boot-class-path -
Do not use the boot classpath for the scala jars.
-
-nowarnor--no-warnings -
Generate no warnings.
-
-opt:OPTIMIZATION1,OPTIMIZATION2 -
Enable optimizations
-
-opt:unreachable-codeEliminate unreachable code, exception handlers guarding no instructions, redundant metadata (debug information, line numbers).
-opt:simplify-jumpsSimplify branching instructions, eliminate unnecessary ones.
-opt:compact-localsEliminate empty slots in the sequence of local variables.
-opt:copy-propagationEliminate redundant local variables and unused values (including closures). Enables unreachable-code.
-opt:redundant-castsEliminate redundant casts using a type propagation analysis.
-opt:box-unboxEliminate box-unbox pairs within the same method (also tuples, xRefs, value class instances). Enables unreachable-code.
-opt:nullness-trackingTrack nullness / non-nullness of local variables and apply optimizations.
-opt:closure-invocationsRewrite closure invocations to the implementation method.
-opt:allow-skip-core-module-initAllow eliminating unused module loads for core modules of the standard library (e.g., Predef, ClassTag).
-opt:assume-modules-non-nullAssume loading a module never results in null (happens if the module is accessed in its super constructor).
-opt:allow-skip-class-loadingAllow optimizations that can skip or delay class loading.
-opt:inlineInline method invocations according to -Yopt-inline-heuristics and -opt-inline-from.
-opt:l:noneDisable optimizations. Takes precedence:
-opt:l:none,+box-unbox/-opt:l:none -opt:box-unboxdon`t enable box-unbox.-opt:l:defaultEnable default optimizations: unreachable-code.
-opt:l:methodEnable intra-method optimizations: unreachable-code,simplify-jumps,compact-locals,copy-propagation,redundant-casts,box-unbox,nullness-tracking,closure-invocations,allow-skip-core-module-init,assume-modules-non-null,allow-skip-class-loading.
-opt:l:inlineEnable cross-method optimizations (note: inlining requires -opt-inline-from): l:method,inline.
-
-opt-inline-from PATTERNS1,PATTERNS2 -
Patterns for classfile names from which to allow inlining,
helpfor details. -
-opt-warnings:WARNING1,WARNING2 -
Enable optimizer warnings
-
-opt-warnings:noneNo optimizer warnings.
-opt-warnings:at-inline-failed-summaryOne-line summary if there were @inline method calls that could not be inlined.
-opt-warnings:at-inline-failedA detailed warning for each @inline method call that could not be inlined.
-opt-warnings:any-inline-failedA detailed warning for every callsite that was chosen for inlining by the heuristics, but could not be inlined.
-opt-warnings:no-inline-mixedIn mixed compilation, warn at callsites methods defined in java sources (the inlining decision cannot be made without bytecode).
-opt-warnings:no-inline-missing-bytecodeWarn if an inlining decision cannot be made because a the bytecode of a class or member cannot be found on the compilation classpath.
-opt-warnings:no-inline-missing-attributeWarn if an inlining decision cannot be made because a Scala classfile does not have a ScalaInlineInfo attribute.
-
-optimizeor-optimise -
Enables optimizations.
-
-printor--print -
Print program with Scala-specific features removed.
-
-release RELEASEor--release RELEASE -
Compile for a specific version of the Java platform. Supported targets: 8, 11, or any higher version listed at https://docs.scala-lang.org/overviews/jdk-compatibility/overview.html
-
-sourcepath PATHor--source-path PATH -
Specify location(s) of source files.
-
-target:TARGETor--target:TARGET -
Target platform for object files. ([8],9,10,11,12)
Default:8
-
-target:8-target:9-target:10-target:11-target:12
-
-toolcp PATHor--tool-class-path PATH -
Add to the runner classpath.
-
-uncheckedor--unchecked -
Enable additional warnings where generated code depends on assumptions.
-
-uniqidor--unique-id -
Uniquely tag all identifiers in debugging output.
-
-usejavacpor--use-java-class-path -
Utilize the java.class.path in classpath resolution.
-
-usemanifestcpor--use-manifest-class-path -
Utilize the manifest in classpath resolution.
-
-verboseor--verbose -
Output messages about what the compiler is doing.
-
-versionor--version -
Print product version and exit.
-
@<file> -
A text file containing compiler arguments (options and source files)
Advanced Settings
-
-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 ARG -
Calls to @elidable methods are omitted if method priority is lower than argument
Default:-2147483648
-
-Xexperimental -
Former graveyard for language-forking extensions.
-
-Xfuture -
Replaced by -Xsource.
-
-Xgenerate-phase-graph FILE -
Generate the phase graphs (outputs .dot files) to fileX.dot.
-
-Xlint:WARNING1,WARNING2 -
Enable recommended warnings
-
-Xlint:adapted-argsWarn if an argument list is modified to match the receiver.
-Xlint:nullary-unitWarn when nullary methods return Unit.
-Xlint:inaccessibleWarn about inaccessible types in method signatures.
-Xlint:infer-anyWarn when a type argument is inferred to be
Any.-Xlint:missing-interpolatorA string literal appears to be missing an interpolator id.
-Xlint:doc-detachedA Scaladoc comment appears to be detached from its element.
-Xlint:private-shadowA private field (or class parameter) shadows a superclass field.
-Xlint:type-parameter-shadowA local type parameter shadows a type already in scope.
-Xlint:poly-implicit-overloadParameterized overloaded implicit methods are not visible as view bounds.
-Xlint:option-implicitOption.apply used implicit view.
-Xlint:delayedinit-selectSelecting member of DelayedInit.
-Xlint:package-object-classesClass or object defined in package object.
-Xlint:stars-alignPattern sequence wildcard must align with sequence component.
-Xlint:constantEvaluation of a constant arithmetic expression results in an error.
-Xlint:unusedEnable -Wunused:imports,privates,locals,implicits.
-Xlint:nonlocal-returnA return statement used an exception for flow control.
-Xlint:implicit-not-foundCheck @implicitNotFound and @implicitAmbiguous messages.
-Xlint:serial@SerialVersionUID on traits and non-serializable classes.
-Xlint:valpatternEnable pattern checks in val definitions.
-Xlint:eta-zeroWarn on eta-expansion (rather than auto-application) of zero-ary method.
-Xlint:eta-samWarn on eta-expansion to meet a Java-defined functional interface that is not explicitly annotated with @FunctionalInterface.
-Xlint:deprecationEnable linted deprecations.
-
-Xmacro-settings OPTION1,OPTION2 -
Custom settings for macros.
-
-Xmain-class PATH -
Class for manifest’s Main-Class entry (only useful with -d jar)
-
-Xmaxerrs ARG -
Maximum errors to print
Default:100
-
-Xmaxwarns ARG -
Maximum warnings to print
Default:100
-
-Xmigration VERSION -
Warn about constructs whose behavior may have changed since version.
Default:none
-
-Xmixin-force-forwarders:MODE -
Generate forwarder methods in classes inhering concrete methods from traits. Default:
Default:true,helpto list choices.true
-
-Xmixin-force-forwarders:trueAlways generate mixin forwarders.
-Xmixin-force-forwarders:junitGenerate mixin forwarders for JUnit-annotated methods (JUnit 4 does not support default methods).
-Xmixin-force-forwarders:falseOnly generate mixin forwarders required for program correctness.
-
-Xno-forwarders -
Do not generate static forwarders in mirror classes.
-
-Xno-patmat-analysis -
Don’t perform exhaustivity/unreachability analysis. Also, ignore @switch annotation.
-
-Xnojline -
Do not use JLine for editing.
-
-Xplugin PATHS1,PATHS2 -
Load a plugin from each classpath.
-
-Xplugin-disable PLUGIN1,PLUGIN2 -
Disable plugins by name.
-
-Xplugin-list -
Print a synopsis of loaded plugins.
-
-Xplugin-require PLUGIN1,PLUGIN2 -
Abort if a named plugin is not loaded.
-
-Xpluginsdir PATH -
Path to search for plugin archives.
Default:
-
-Xprompt -
Display a prompt after each error (debugging option).
-
-Xreporter CLASSNAME -
Specify a custom reporter for compiler messages.
Default:scala.tools.nsc.reporters.ConsoleReporter
-
-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.
Default:2.13.0
-
-Xsource-reader CLASSNAME -
Specify a custom method for reading source files.
-
-Xverify -
Verify generic signatures in generated bytecode.
-
-Xxml:PROPERTY1,PROPERTY2 -
Configure XML parsing.
-
-Xxml:coalescingConvert PCData to Text and coalesce sibling nodes
Verbose Settings
-
-Vbrowse ARGor-Ybrowse ARG -
Browse the abstract syntax tree after phases
-
-Vclasspathor-Ylog-classpath -
Output information about what classpath is being applied.
-
-Vdebugor-Ydebug -
Increase the quantity of debugging output.
-
-Vdocor-Ydoc-debug -
Trace scaladoc activity.
-
-Vfree-termsor-Xlog-free-terms -
Print a message when reification creates a free term.
-
-Vfree-typesor-Xlog-free-types -
Print a message when reification resorts to generating a free type.
-
-Vhot-statisticsor-Yhot-statistics -
Enable
-Vstatisticsto also print hot statistics. -
-Videor-Yide-debug -
Generate, validate and output trees using the interactive compiler.
-
-Vimplicit-conversionsor-Xlog-implicit-conversions -
Print a message whenever an implicit conversion is inserted.
-
-Vimplicitsor-Xlog-implicits -
Print dependent missing implicits.
-
-Vimplicits-verbose-tree -
Display all intermediate implicits in a chain.
-
-Vimplicits-max-refined ARG -
max chars for printing refined types, abbreviate to
Default:F {...}0
-
-Vtype-diffs -
Print found/required error messages as colored diffs.
-
-Vinline PACKAGE/CLASS.METHODor-Yopt-log-inline PACKAGE/CLASS.METHOD -
Print a summary of inliner activity;
_to print all, prefix match to select. -
-Vissueor-Yissue-debug -
Print stack traces when a context issues an error.
-
-Vlog ARGor-Ylog ARG -
Log operations during phases
-
-Vmacroor-Ymacro-debug-verbose -
Trace macro activities: compilation, generation of synthetics, classloading, expansion, exceptions.
-
-Vmacro-liteor-Ymacro-debug-lite -
Trace macro activities with less output.
-
-Vopt PACKAGE/CLASS.METHODor-Yopt-trace PACKAGE/CLASS.METHOD -
Trace the optimizer progress for methods;
_to print all, prefix match to select. -
-Vpatmator-Ypatmat-debug -
Trace pattern matching translation.
-
-Vphasesor-Xshow-phases -
Print a synopsis of compiler phases.
-
-Vposor-Ypos-debug -
Trace position validation.
-
-Vprint ARGor-Xprint ARG -
Print out program after phases
-
-Vprint-args FILEor-Xprint-args FILE -
Print all compiler arguments to the specified location. Use - to echo to the reporter.
Default:-
-
-Vprint-posor-Xprint-pos -
Print tree positions, as offsets.
-
-Vprint-typesor-Xprint-types -
Print tree types (debugging option).
-
-Vquasiquoteor-Yquasiquote-debug -
Trace quasiquotations.
-
-Vreflective-callsor-Xlog-reflective-calls -
Print a message when a reflective method call is generated
-
-Vreifyor-Yreify-debug -
Trace reification.
-
-Vshow ARGor-Yshow ARG -
(Requires -Xshow-class or -Xshow-object) Show after phases
-
-Vshow-class CLASSor-Xshow-class CLASS -
Show internal representation of class.
-
-Vshow-member-pos OUTPUT STYLEor-Yshow-member-pos OUTPUT STYLE -
Show start and end positions of members (implies -Yrangepos)
-
-Vshow-object OBJECTor-Xshow-object OBJECT -
Show internal representation of object.
-
-Vshow-symkindsor-Yshow-symkinds -
Print abbreviated symbol kinds next to symbol names.
-
-Vshow-symownersor-Yshow-symowners -
Print owner identifiers next to symbol names.
-
-Vstatistics ARGor-Ystatistics ARG -
Print compiler statistics for specific phases phases (default: parser,typer,patmat,erasure,cleanup,jvm)
Default:parser,typer,patmat,erasure,cleanup,jvm
-
-Vsymbolsor-Yshow-syms -
Print the AST symbol hierarchy after each phase.
-
-Vtyperor-Ytyper-debug -
Trace type assignments.
Private Settings
-
-Ybackend-parallelism ARG -
maximum worker threads for backend
Default:1
Min:1
Max:16
-
-Ybackend-worker-queue ARG -
backend threads worker queue size
Default:0
Min:0
Max:1000
-
-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:
Default:none,helpto list choices.none
-
-Ycache-macro-class-loader:noneDon’t cache class loader
-Ycache-macro-class-loader:last-modifiedCache class loader, using file last-modified time to invalidate
-Ycache-macro-class-loader:alwaysCache class loader with no invalidation
-
-Ycache-plugin-class-loader:POLICY -
Policy for caching class loaders for compiler plugins that are dynamically loaded. Default:
Default:none,helpto list choices.none
-
-Ycache-plugin-class-loader:noneDon’t cache class loader
-Ycache-plugin-class-loader:last-modifiedCache class loader, using file last-modified time to invalidate
-Ycache-plugin-class-loader:alwaysCache class loader with no invalidation
-
-Ycheck ARG -
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])
Default:method
-
-Ydelambdafy:inline-Ydelambdafy: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 IMPORT1,IMPORT2 -
Custom root imports, default is
java.lang,scala,scala.Predef. -
-Yjar-compression-level ARG -
compression level to use when writing jar files
Default:-1
Min:-1
Max:9
-
-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)
Default:normal
-
-Ymacro-expand:normal-Ymacro-expand:none-Ymacro-expand: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-cacheor-YdisableFlatCpCaching -
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])
Default:default
-
-Yopt-inline-heuristics:at-inline-annotated-Yopt-inline-heuristics:everything-Yopt-inline-heuristics:default
-
-Ypatmat-exhaust-depth ARG -
off
Default:20
Min:10
Max:2147483647
-
-Yprint-trees:STYLE -
How to print trees when -Vprint is enabled. ([text],compact,format,text+format)
Default:text
-
-Yprint-trees:text-Yprint-trees:compact-Yprint-trees:format-Yprint-trees:text+format
-
-Yprofile-destination FILE -
Profiling output - specify a file or
-for console. -
-Yprofile-enabled -
Enable profiling.
-
-Yprofile-external-tool ARG -
Enable profiling for a phase using an external tool hook. Generally only useful for a single phase phases (default: typer)
Default:typer
-
-Yprofile-run-gc ARG -
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: _)
Default:_
-
-Yprofile-trace FILE -
Capture trace of compilation in Chrome Trace format
Default:profile.trace
-
-Yrangepos -
Use range positions for syntax trees.
-
-Yrecursion ARG -
Set recursion depth used when locking symbols.
Default:0
Min:0
Max:2147483647
-
-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])
Default:error
-
-Yresolve-term-conflict:package-Yresolve-term-conflict:object-Yresolve-term-conflict:error
-
-Yscriptrunner CLASSNAME -
Specify a scala.tools.nsc.ScriptRunner (default, resident, shutdown, or a class name).
Default:default
-
-Yskip ARG -
Skip phases
-
-Ystop-after ARGor-stop ARG -
Stop after phases
-
-Ystop-before ARG -
Stop before phases
-
-Yvalidate-pos ARG -
Validate positions after the given phases (implies -Yrangepos) phases
Warning Settings
-
-Wdead-codeor-Ywarn-dead-code -
Warn when dead code is identified.
-
-Wextra-implicitor-Ywarn-extra-implicit -
Warn when more than one implicit parameter section is defined.
-
-Wmacros:MODEor-Ywarn-macros:MODE -
Enable lint warnings on macro expansions. Default:
Default:before,helpto list choices.before
-
-Wmacros:noneDo not inspect expansions or their original trees when generating unused symbol warnings.
-Wmacros:beforeOnly inspect unexpanded user-written code for unused symbols.
-Wmacros:afterOnly inspect expanded trees when generating unused symbol warnings.
-Wmacros:bothInspect both user-written code and expanded trees when generating unused symbol warnings.
-
-Wnumeric-widenor-Ywarn-numeric-widen -
Warn when numerics are widened.
-
-Woctal-literalor-Ywarn-octal-literal -
Warn on obsolete octal syntax.
-
-Wself-implicitor-Ywarn-self-implicit -
Warn when an implicit resolves to an enclosing self-definition.
-
-Wunused:WARNING1,WARNING2or-Ywarn-unused:WARNING1,WARNING2 -
Enable or disable specific
unusedwarnings -
-Wunused:importsWarn if an import selector is not referenced.
-Wunused:patvarsWarn if a variable bound in a pattern is unused.
-Wunused:privatesWarn if a private member is unused.
-Wunused:localsWarn if a local definition is unused.
-Wunused:explicitsWarn if an explicit parameter is unused.
-Wunused:implicitsWarn if an implicit parameter is unused.
-Wunused:paramsEnable -Wunused:explicits,implicits.
-Wunused:linted-Xlint:unused.
-
-Wvalue-discardor-Ywarn-value-discard -
Warn when non-Unit expression results are unused.
-
-Xlint:WARNING1,WARNING2 -
Enable recommended warnings
-
-Xlint:adapted-argsWarn if an argument list is modified to match the receiver.
-Xlint:nullary-unitWarn when nullary methods return Unit.
-Xlint:inaccessibleWarn about inaccessible types in method signatures.
-Xlint:infer-anyWarn when a type argument is inferred to be
Any.-Xlint:missing-interpolatorA string literal appears to be missing an interpolator id.
-Xlint:doc-detachedA Scaladoc comment appears to be detached from its element.
-Xlint:private-shadowA private field (or class parameter) shadows a superclass field.
-Xlint:type-parameter-shadowA local type parameter shadows a type already in scope.
-Xlint:poly-implicit-overloadParameterized overloaded implicit methods are not visible as view bounds.
-Xlint:option-implicitOption.apply used implicit view.
-Xlint:delayedinit-selectSelecting member of DelayedInit.
-Xlint:package-object-classesClass or object defined in package object.
-Xlint:stars-alignPattern sequence wildcard must align with sequence component.
-Xlint:constantEvaluation of a constant arithmetic expression results in an error.
-Xlint:unusedEnable -Wunused:imports,privates,locals,implicits.
-Xlint:nonlocal-returnA return statement used an exception for flow control.
-Xlint:implicit-not-foundCheck @implicitNotFound and @implicitAmbiguous messages.
-Xlint:serial@SerialVersionUID on traits and non-serializable classes.
-Xlint:valpatternEnable pattern checks in val definitions.
-Xlint:eta-zeroWarn on eta-expansion (rather than auto-application) of zero-ary method.
-Xlint:eta-samWarn on eta-expansion to meet a Java-defined functional interface that is not explicitly annotated with @FunctionalInterface.
-Xlint:deprecationEnable linted deprecations.
IDE-specific Settings
-
-Ypresentation-any-thread -
Allow use of the presentation compiler from any thread
-
-Ypresentation-debug -
Enable debugging output for the presentation compiler.
-
-Ypresentation-delay ARG -
Wait number of ms after typing before starting typechecking
Default:0
Min:0
Max:999
-
-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.
Targeting a version of the JVM
Applications or libraries targeting the JVM may wish to specify a target version.
The -release option specifies the target version, such as “8” or “18”.
Like the option for javac, it allows building against an earlier version of the JDK. It will compile against the API for that version and also output class files for that version.
The deprecated option -target does not compile against the desired API, but only specifies a target class file format.
Additional resources
Compilation Phases
- parser
- parse source into ASTs, perform simple desugaring
- namer
- resolve names, attach symbols to named trees
- packageobjects
- load package objects
- typer
- the meat and potatoes: type the trees
- superaccessors
- add super accessors in traits and nested classes
- extmethods
- add extension methods for inline classes
- pickler
- serialize symbol tables
- refchecks
- reference/override checking, translate nested objects
- patmat
- translate match expressions
- uncurry
- uncurry, translate function values to anonymous classes
- fields
- synthesize accessors and fields, add bitmaps for lazy vals
- tailcalls
- replace tail calls by jumps
- specialize
- @specialized-driven class and method specialization
- explicitouter
- this refs to outer pointers
- erasure
- erase types, add interfaces for traits
- posterasure
- clean up erased inline classes
- lambdalift
- move nested functions to top level
- constructors
- move field definitions into constructors
- flatten
- eliminate inner classes
- mixin
- mixin composition
- cleanup
- platform-specific cleanups, generate reflective calls
- delambdafy
- remove lambdas
- jvm
- generate JVM bytecode
- terminal
- the last phase during a compilation run