Permalink
Browse files

Noticed that Settings post-set hooks were not b...

Noticed that Settings post-set hooks were not being set in the place
where they ought to be, so multiple setting settings (such as -optimise)
were not flipping all the right bits when set programmatically instead
of via command line options. This may be a factor in inlining issues,
though by itself it does not appear to solve anything. No review.
  • Loading branch information...
1 parent 406e54b commit 4f12f2af975af384202ccd123c067d8e04bff516 @paulp paulp committed Apr 12, 2010
Showing with 8 additions and 6 deletions.
  1. +8 −6 src/compiler/scala/tools/nsc/settings/MutableSettings.scala
@@ -95,10 +95,7 @@ class MutableSettings(val errorFn: String => Unit) extends AbsSettings with Scal
): Option[List[String]] =
lookupSetting(cmd) match {
case None => errorFn("Parameter '" + cmd + "' is not recognised by Scalac.") ; None
- case Some(cmd) =>
- val res = setter(cmd)(args)
- cmd.postSetHook()
- res
+ case Some(cmd) => setter(cmd)(args)
}
// if arg is of form -Xfoo:bar,baz,quux
@@ -191,10 +188,15 @@ class MutableSettings(val errorFn: String => Unit) extends AbsSettings with Scal
trait SettingValue extends AbsSettingValue {
protected var v: T
protected var setByUser: Boolean = false
+ def postSetHook(): Unit
def isDefault: Boolean = !setByUser
def value: T = v
- def value_=(arg: T) = { setByUser = true ; v = arg }
+ def value_=(arg: T) = {
+ setByUser = true
+ v = arg
+ postSetHook()
+ }
}
/** A class for holding mappings from source directories to
@@ -305,7 +307,7 @@ class MutableSettings(val errorFn: String => Unit) extends AbsSettings with Scal
abstract class Setting(val name: String, val helpDescription: String) extends AbsSetting with SettingValue with Mutable {
/** Will be called after this Setting is set for any extra work. */
private var _postSetHook: this.type => Unit = (x: this.type) => ()
- def postSetHook() = { _postSetHook(this) ; this }
+ def postSetHook(): Unit = _postSetHook(this)
def withPostSetHook(f: this.type => Unit): this.type = { _postSetHook = f ; this }
/** The syntax defining this setting in a help string */

0 comments on commit 4f12f2a

Please sign in to comment.