我使用SBT建设项目,并在我的Build.scala
:发出警告名Scala的阴影2.11
scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature", "-Xfatal-warnings")
如何配置该项目上的名称/可变阴影警告?我浏览过源here和here,但在许多选项中没有看到我正在寻找的内容。对this old question的评论提到一个标志-Ywarn-shadowing
,似乎并不存在。
我使用SBT建设项目,并在我的Build.scala
:发出警告名Scala的阴影2.11
scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature", "-Xfatal-warnings")
如何配置该项目上的名称/可变阴影警告?我浏览过源here和here,但在许多选项中没有看到我正在寻找的内容。对this old question的评论提到一个标志-Ywarn-shadowing
,似乎并不存在。
如related question所示,您可以开始使用-X
进行探索。然后,我尝试-Xlint:help
,这为产生阴影的一些设置:
Information:scalac: 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.
也许-Xlint:private-shadow
是你想要的吗?
谢谢,这有助于,但我正在寻找变量的阴影,例如嵌套作用域中的'val',或者映射函数或方法参数的'val'。它看起来可能不可能,这对我来说有点杜鹃。 – jberryman
有许多斯卡拉短绒工具。 Scapegoat有一个选项VariableShadowing
。我没有看到更受欢迎的绒毛中的阴影选项,但是您可以自己实现一个。
也许有人知道一个scala守护者或疣卸妆。我手边没有看到它。还有其他用例:http://stackoverflow.com/questions/27587965/scala-making-sure-that-a-field-from-the-superclass-is-used https://issues.scala-lang.org /浏览/ SI-9100 https://issues.scala-lang.org/browse/SI-4762 –
这包括情绪:http://stackoverflow.com/questions/12385293/how-can-i-get-scalac - 告诉我,如果我有,未使用的变量 –