diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2014-02-17 18:54:46 +0100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2014-02-17 21:30:51 +0100 |
commit | 0538e7fd086c39226b2d005865eee07bb83f5b2e (patch) | |
tree | ce981a3175ee5ef92e3705a3ca728129c079ab3f /src/compiler/scala/tools/nsc/settings/MutableSettings.scala | |
parent | 55549bfa41f4a19c9556b71791de35875e8229dc (diff) | |
download | scala-0538e7fd086c39226b2d005865eee07bb83f5b2e.tar.gz scala-0538e7fd086c39226b2d005865eee07bb83f5b2e.tar.bz2 scala-0538e7fd086c39226b2d005865eee07bb83f5b2e.zip |
Group settings should honor user-set individual options
In the last commit, we added the ability to explicitly disable
boolean settings form the command line.
This commit changes group settings (like -optimize), to leave
them alone if set explicitly.
Examples:
`scalac -Xlint -Ywarn-unused:false -optimize -Yinline:false`
The mechanism for such settings has also been refactored to
`MutableSettings`, to let use reuse this for `-Xlint`.
Diffstat (limited to 'src/compiler/scala/tools/nsc/settings/MutableSettings.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/settings/MutableSettings.scala | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/settings/MutableSettings.scala b/src/compiler/scala/tools/nsc/settings/MutableSettings.scala index a8421c8b15..3590254128 100644 --- a/src/compiler/scala/tools/nsc/settings/MutableSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/MutableSettings.scala @@ -679,4 +679,14 @@ class MutableSettings(val errorFn: String => Unit) else name + "[:phases]" ) } + + /** Internal use - syntax enhancements. */ + protected class EnableSettings[T <: BooleanSetting](val s: T) { + def enablingIfNotSetByUser(toEnable: List[BooleanSetting]): s.type = s withPostSetHook (_ => toEnable foreach (sett => if (!sett.isSetByUser) sett.value = s.value)) + def enabling(toEnable: List[BooleanSetting]): s.type = s withPostSetHook (_ => toEnable foreach (_.value = s.value)) + def disabling(toDisable: List[BooleanSetting]): s.type = s withPostSetHook (_ => toDisable foreach (_.value = !s.value)) + def andThen(f: s.T => Unit): s.type = s withPostSetHook (setting => f(setting.value)) + } + import scala.language.implicitConversions + protected implicit def installEnableSettings[T <: BooleanSetting](s: T): EnableSettings[T] = new EnableSettings(s) } |