2017-08-14 34 views
2

在斯卡拉2.12有沒有這些選項之間的區別:編譯器選項警告VS棉短絨

  • -Xlint:adapted-args VS -Ywarn-adapted-args
  • -Xlint:nullary-unit VS -Ywarn-nullary-unit
  • -Xlint:inaccessible VS -Ywarn-inaccessible
  • -Xlint:nullary-override VS -Ywarn-nullary-override
  • -Xlint:infer-any vs -Ywarn-infer-any

如果不是,哪一個更合理?我也編譯fatal-warnings,幾乎所有-Ywarn-Xlint選項。

回答

3

如果運行scalac -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 viewbounds. 
    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. 
    constant     Evaluation of a constant arithmetic expression results in an error. 
    unused      Enable -Ywarn-unused:imports,privates,locals,implicits. 
Default: All choices are enabled by default. 

所以有選擇Xlint選項,或直接使用相應的標誌沒有任何區別。我只想用-Xlint去(的選項,因此所有默認啓用),並刪除我不需要的那些,例如

-Xlint:-unused,_

,使一切,但unused標誌。

+0

這當然是一個更好的方法,我在做什麼。但是它沒有解釋通過linter或通過警告「使用」選項之間有什麼區別,它們是否完全一樣? –

+1

是的,這些選項完全相同,只是由不同的標誌啓用 –