4

scalax -Xlint help 提供以下信息:

$ scalac -Xlint:help
Enable or disable specific warnings
  adapted-args               Warn if an argument list is modified to match the receiver.
  nullary-unit               Warn when nullary methods return Unit.
  inaccessible               Warn about inaccessible types in method signatures.
  nullary-override           Warn when non-nullary `def f()' overrides nullary `def f'.
  infer-any                  Warn when a type argument is inferred to be `Any`.
  missing-interpolator       A string literal appears to be missing an interpolator id.
  doc-detached               A Scaladoc comment appears to be detached from its element.
  private-shadow             A private field (or class parameter) shadows a superclass field.
  type-parameter-shadow      A local type parameter shadows a type already in scope.
  poly-implicit-overload     Parameterized overloaded implicit methods are not visible as view bounds.
  option-implicit            Option.apply used implicit view.
  delayedinit-select         Selecting member of DelayedInit.
  by-name-right-associative  By-name parameter of right associative operator.
  package-object-classes     Class or object defined in package object.
  unsound-match              Pattern match may not be typesafe.
  stars-align                Pattern sequence wildcard must align with sequence component.

有没有办法启用所有检查?的语义是scalac -Xlint什么?它会启用所有功能吗?默认设置(哪个)?什么都不会?

注意:Scala 2.11.8 和 sbt 0.13.9

如果较新的版本提供不同的行为/功能,请告诉我,因为更新它们不是问题

4

1 回答 1

9

-Xlint 目前的意思 -Xlint:_,但这需要明确

从历史上看,总是存在过于嘈杂或不可靠而无法默认启用的警告,因此总是有警告被排除在-Xlint.

目前,有一个这样的 lintable,但它没有连接到命令行选项。

曾经有一个-Ywarn-all意思是-Xlint加上其他警告。目前尚不清楚为什么该选项消失了。

在某一时刻,-Xlint:_将意味着-Ywarn-all-Xlint意味着一个推荐的子集,但事实证明,人们喜欢禁用一个或两个 lint 规则-Xlint:-annoying,_,如果启用任意许多其他嘈杂的 lint 规则,这将更难做到。

通常,scalac -X显示默认值;但可能scalac -Xlint:help会被改进以显示其默认行为。对于类似-Yopt.

$ scalac -help
Usage: scalac <options> <source files>
where possible standard options include:
  -X                              Print a synopsis of advanced options.


$ scalac -X
Usage: scalac <options> <source files>

-- Notes on option parsing --
Boolean settings are always false unless set.
Where multiple values are accepted, they should be comma-separated.
  example: -Xplugin:option1,option2
<phases> means one or a comma-separated list of:
  (partial) phase names, phase ids, phase id ranges, or the string "all".
  example: -Xprint:all prints all phases.
  example: -Xprint:expl,24-26 prints phases explicitouter, closelim, dce, jvm.
  example: -Xprint:-4 prints only the phases up to typer.

Possible advanced options include:
  -Xlint:<_,warning,-warning>    Enable or disable specific warnings: `_' for all, `-Xlint:help' to list
于 2016-06-25T20:02:06.153 回答