diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2014-09-03 09:38:36 +0200 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@gmail.com> | 2014-09-08 21:37:34 +0200 |
commit | 861ad72b59c5ea7856b2853c092aaeb15453caea (patch) | |
tree | cb8b42bcc3f137f3c150a570ea257142a866e574 /src | |
parent | 7655a70489f565a5a7a165f893b4a1e44c3cb2b8 (diff) | |
download | scala-861ad72b59c5ea7856b2853c092aaeb15453caea.tar.gz scala-861ad72b59c5ea7856b2853c092aaeb15453caea.tar.bz2 scala-861ad72b59c5ea7856b2853c092aaeb15453caea.zip |
Address PR feedback, fix MultiChoiceSetting.contains
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/settings/MutableSettings.scala | 7 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/settings/Warnings.scala | 33 |
2 files changed, 18 insertions, 22 deletions
diff --git a/src/compiler/scala/tools/nsc/settings/MutableSettings.scala b/src/compiler/scala/tools/nsc/settings/MutableSettings.scala index 78d7061066..1f75afd49a 100644 --- a/src/compiler/scala/tools/nsc/settings/MutableSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/MutableSettings.scala @@ -553,7 +553,7 @@ class MutableSettings(val errorFn: String => Unit) } /** - * Each [[MultiChoiceSetting]] takes a MultiChoiceEnumeration as domain. The enumartion may + * Each [[MultiChoiceSetting]] takes a MultiChoiceEnumeration as domain. The enumeration may * use the Choice class to define values, or simply use the default `Value` constructor: * * object SettingDomain extends MultiChoiceEnumeration { val arg1, arg2 = Value } @@ -572,7 +572,8 @@ class MutableSettings(val errorFn: String => Unit) case class Choice(name: String, help: String = "", expandsTo: List[Choice] = Nil) extends Val(name) } - /** A Setting that collects string-valued settings from an enumerated domain. + /** + * A Setting that collects string-valued settings from an enumerated domain. * - These choices can be turned on or off: "-option:on,-off" * - If an option is set both on and off, then the option is on * - The choice "_" enables all choices that have not been explicitly disabled @@ -744,7 +745,7 @@ class MutableSettings(val errorFn: String => Unit) sawHelp = false } def unparse: List[String] = value.toList map (s => s"$name:$s") - def contains(s: String) = value contains (domain withName s) + def contains(s: String) = domain.values.find(_.toString == s).exists(value.contains) } /** A setting that accumulates all strings supplied to it, diff --git a/src/compiler/scala/tools/nsc/settings/Warnings.scala b/src/compiler/scala/tools/nsc/settings/Warnings.scala index 574825874d..c400e8c29c 100644 --- a/src/compiler/scala/tools/nsc/settings/Warnings.scala +++ b/src/compiler/scala/tools/nsc/settings/Warnings.scala @@ -58,7 +58,7 @@ trait Warnings { val PackageObjectClasses = LintWarning("package-object-classes", "Class or object defined in package object.") val UnsoundMatch = LintWarning("unsound-match", "Pattern match may not be typesafe.") - def allWarnings = values.toSeq.asInstanceOf[Seq[LintWarning]] + def allLintWarnings = values.toSeq.asInstanceOf[Seq[LintWarning]] } import LintWarnings._ @@ -91,24 +91,19 @@ trait Warnings { def YwarnInferAny = warnInferAny // The Xlint warning group. - val lint: MultiChoiceSetting[LintWarnings.type] = { - import LintWarnings._ - - allWarnings.sortBy(_.name) foreach { - case l: LintWarning if l.yAliased => - BooleanSetting(s"-Ywarn-${l.name}", {l.help}) withPostSetHook { s => - lint.add(if (s) l.name else s"-${l.name}") - } // withDeprecationMessage s"Enable -Xlint:${c._1}" - case _ => - } - - MultiChoiceSetting( - name = "-Xlint", - helpArg = "warning", - descr = "Enable or disable specific warnings", - domain = LintWarnings, - default = Some(List("_")) - ) + val lint = MultiChoiceSetting( + name = "-Xlint", + helpArg = "warning", + descr = "Enable or disable specific warnings", + domain = LintWarnings, + default = Some(List("_"))) + + allLintWarnings foreach { + case w if w.yAliased => + BooleanSetting(s"-Ywarn-${w.name}", {w.help}) withPostSetHook { s => + lint.add(if (s) w.name else s"-${w.name}") + } // withDeprecationMessage s"Enable -Xlint:${c._1}" + case _ => } private lazy val warnSelectNullable = BooleanSetting("-Xcheck-null", "This option is obsolete and does nothing.") |