How can I find a description of scala compiler flags/options?

前端 未结 2 1393
-上瘾入骨i
-上瘾入骨i 2021-02-02 07:21

How can I find all of the flags for the latest scalac version? After googling for hours I have found only outdated docs. (for example, they don\'t even mention \"-feature\" flag

相关标签:
2条回答
  • 2021-02-02 08:06

    Edit: Documentation for Scala Compiler Options has been posted.

    Most of us get by with scalac -help, scalac -X and scalac -Y.

    Don't forget to scala -help, too.

    Edit: sbt user can do the usual:

    > set scalacOptions in Compile += "-X"
    > compile
    [snip]
    [info]   -Xcheck-null                   Warn upon selection of nullable reference.
    [info]   -Xcheckinit                    Wrap field accessors to throw an exception on uninitialized access.
    [info]   -Xdisable-assertions           Generate no assertions or assumptions.
    [info]   -Xdivergence211                Turn on the 2.11 behavior of implicit divergence not terminating recursive implicit searches (SI-7291).
    [info]   -Xelide-below <n>              Calls to @elidable methods are omitted if method priority is lower than argument
    [info]   -Xexperimental                 Enable experimental extensions.
    [info]   -Xfatal-warnings               Fail the compilation if there are any warnings.
    [snip]
    

    At least the man page was updated recently:

    https://issues.scala-lang.org/browse/SI-7824

    0 讨论(0)
  • 2021-02-02 08:18

    The closest I have been able to find is the relevant source files for the compiler. Unfortunately the options are spread among several files. As of this writing, it breaks down like so:

    • StandardScalaSettings (for basic flags)
    • ScalaSettings (for advanced flags)

    These will of course be for the current development version of the compiler, so if you want options for a specific version of scalac, you'll need to use the "branch" drop-down menu to view the correct version tag.

    0 讨论(0)
提交回复
热议问题