diff options
3 files changed, 28 insertions, 22 deletions
diff --git a/src/compiler/scala/reflect/internal/settings/MutableSettings.scala b/src/compiler/scala/reflect/internal/settings/MutableSettings.scala index 3bf296760f..b756408541 100644 --- a/src/compiler/scala/reflect/internal/settings/MutableSettings.scala +++ b/src/compiler/scala/reflect/internal/settings/MutableSettings.scala @@ -12,10 +12,12 @@ package settings abstract class MutableSettings extends AbsSettings { type Setting <: SettingValue + type BooleanSetting <: Setting { type T = Boolean } + type IntSetting <: Setting { type T = Int } // basically this is a value which remembers if it's been modified trait SettingValue extends AbsSettingValue { - protected var v: T = _ + protected var v: T protected var setByUser: Boolean = false def postSetHook(): Unit = () @@ -29,15 +31,15 @@ abstract class MutableSettings extends AbsSettings { } } - def overrideObjects: SettingValue { type T = Boolean } - def printtypes: SettingValue { type T = Boolean } - def debug: SettingValue { type T = Boolean } - def YdepMethTpes: SettingValue { type T = Boolean } - def Ynotnull: SettingValue { type T = Boolean } - def explaintypes: SettingValue { type T = Boolean } - def verbose: SettingValue { type T = Boolean } - def uniqid: SettingValue { type T = Boolean } - def Xprintpos: SettingValue { type T = Boolean } - def Yrecursion: SettingValue { type T = Int } - def maxClassfileName: SettingValue { type T = Int } + def overrideObjects: BooleanSetting + def printtypes: BooleanSetting + def debug: BooleanSetting + def YdepMethTpes: BooleanSetting + def Ynotnull: BooleanSetting + def explaintypes: BooleanSetting + def verbose: BooleanSetting + def uniqid: BooleanSetting + def Xprintpos: BooleanSetting + def Yrecursion: IntSetting + def maxClassfileName: IntSetting }
\ No newline at end of file diff --git a/src/compiler/scala/reflect/runtime/Settings.scala b/src/compiler/scala/reflect/runtime/Settings.scala index 4bd72ce47b..86e8457850 100644 --- a/src/compiler/scala/reflect/runtime/Settings.scala +++ b/src/compiler/scala/reflect/runtime/Settings.scala @@ -7,16 +7,18 @@ package runtime */ class Settings extends internal.settings.MutableSettings { - class Setting extends SettingValue + trait Setting extends SettingValue { } class BooleanSetting(x: Boolean) extends Setting { type T = Boolean - v = x + protected var v: Boolean = x + override def value: Boolean = v } class IntSetting(x: Int) extends Setting { type T = Int - v = x + protected var v: Int = x + override def value: Int = v } val overrideObjects = new BooleanSetting(false) diff --git a/src/compiler/scala/tools/nsc/settings/MutableSettings.scala b/src/compiler/scala/tools/nsc/settings/MutableSettings.scala index 0ccb8df4bb..67a556f6f0 100644 --- a/src/compiler/scala/tools/nsc/settings/MutableSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/MutableSettings.scala @@ -361,7 +361,8 @@ class MutableSettings(val errorFn: String => Unit) parser: String => Option[Int]) extends Setting(name, descr) { type T = Int - v = default + protected var v: Int = default + override def value: Int = v // not stable values! val IntMin = Int.MinValue @@ -418,7 +419,8 @@ class MutableSettings(val errorFn: String => Unit) descr: String) extends Setting(name, descr) { type T = Boolean - v = false + protected var v: Boolean = false + override def value: Boolean = v def tryToSet(args: List[String]) = { value = true ; Some(args) } def unparse: List[String] = if (value) List(name) else Nil @@ -434,7 +436,7 @@ class MutableSettings(val errorFn: String => Unit) descr: String) extends Setting(name, descr) { type T = List[String] - v = Nil + protected var v: T = Nil def tryToSet(args: List[String]) = args match { case x :: xs if x startsWith prefix => @@ -455,7 +457,7 @@ class MutableSettings(val errorFn: String => Unit) val default: String) extends Setting(name, descr) { type T = String - v = default + protected var v: T = default def tryToSet(args: List[String]) = args match { case Nil => errorAndValue("missing argument", None) @@ -505,7 +507,7 @@ class MutableSettings(val errorFn: String => Unit) descr: String) extends Setting(name, descr) { type T = List[String] - v = Nil + protected var v: T = Nil def appendToValue(str: String) { value ++= List(str) } def tryToSet(args: List[String]) = { @@ -532,7 +534,7 @@ class MutableSettings(val errorFn: String => Unit) val default: String) extends Setting(name, descr + choices.mkString(" (", ",", ") default:" + default)) { type T = String - v = default + protected var v: T = default def indexOfChoice: Int = choices indexOf value private def usageErrorMessage = { @@ -573,7 +575,7 @@ class MutableSettings(val errorFn: String => Unit) private[nsc] def this(name: String, descr: String) = this(name, descr, "") type T = List[String] - v = Nil + protected var v: T = Nil override def value = if (v contains "all") List("all") else super.value private lazy val (numericValues, stringValues) = value filterNot (_ == "" ) partition (_ forall (ch => ch.isDigit || ch == '-')) |