summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-08-06 14:09:59 -0700
committerPaul Phillips <paulp@improving.org>2012-08-06 14:09:59 -0700
commit963aabbeb45e042f4b0d6f5ec13edb0136cbf441 (patch)
tree0afe1b93e90088dd35c426c56f559a8116342cfe /src
parentb65b7b13924a86d38e04873f9c68d69590dec661 (diff)
downloadscala-963aabbeb45e042f4b0d6f5ec13edb0136cbf441.tar.gz
scala-963aabbeb45e042f4b0d6f5ec13edb0136cbf441.tar.bz2
scala-963aabbeb45e042f4b0d6f5ec13edb0136cbf441.zip
Fix for SI-4945, repl hang on -i input.
Other breakage had accumulated among Settings. I determined that once upon a time, "MultiStringSetting" accepted arguments like this: scala -foo bip bop bar Somewhere this was changed to force a : argument, like scala -foo:bip,bop,bar This incurs breakage. The repl has always advertised its -i option without a colon and it has always been a MultiStringSetting. Forcing everything into the : seemed like the wrong thing, especially because it will stomp on any whitespace containing arguments, whereas in the original form scala -foo bip "bop bar" baz will yield its arguments as given. So lacking any good ideas and knowing something probably depends on each way already, I made it work both ways.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/reflect/macros/runtime/Settings.scala8
-rw-r--r--src/compiler/scala/tools/nsc/MainGenericRunner.scala4
-rw-r--r--src/compiler/scala/tools/nsc/settings/MutableSettings.scala4
-rw-r--r--src/reflect/scala/reflect/internal/settings/MutableSettings.scala3
-rw-r--r--src/reflect/scala/reflect/runtime/Settings.scala41
5 files changed, 37 insertions, 23 deletions
diff --git a/src/compiler/scala/reflect/macros/runtime/Settings.scala b/src/compiler/scala/reflect/macros/runtime/Settings.scala
index b7dba665fa..9c24273cd7 100644
--- a/src/compiler/scala/reflect/macros/runtime/Settings.scala
+++ b/src/compiler/scala/reflect/macros/runtime/Settings.scala
@@ -5,9 +5,9 @@ trait Settings {
self: Context =>
def settings: List[String] = {
- val optionName = universe.settings.XmacroSettings.name
- val settings = compilerSettings.find(opt => opt.startsWith(optionName)).map(opt => opt.substring(optionName.length + 1)).getOrElse("")
- settings.split(",").toList
+ val us = universe.settings
+ import us._
+ userSetSettings collectFirst { case x: MultiStringSetting if x.name == XmacroSettings.name => x.value } getOrElse Nil
}
def compilerSettings: List[String] = universe.settings.recreateArgs
@@ -33,4 +33,4 @@ trait Settings {
try op
finally setCompilerSettings(old)
}
-} \ No newline at end of file
+}
diff --git a/src/compiler/scala/tools/nsc/MainGenericRunner.scala b/src/compiler/scala/tools/nsc/MainGenericRunner.scala
index cc1139f8a7..f1c3e80b83 100644
--- a/src/compiler/scala/tools/nsc/MainGenericRunner.scala
+++ b/src/compiler/scala/tools/nsc/MainGenericRunner.scala
@@ -58,6 +58,10 @@ class MainGenericRunner {
def isI = !settings.loadfiles.isDefault
def dashi = settings.loadfiles.value
+ // Deadlocks on startup under -i unless we disable async.
+ if (isI)
+ settings.Yreplsync.value = true
+
def combinedCode = {
val files = if (isI) dashi map (file => File(file).slurp()) else Nil
val str = if (isE) List(dashe) else Nil
diff --git a/src/compiler/scala/tools/nsc/settings/MutableSettings.scala b/src/compiler/scala/tools/nsc/settings/MutableSettings.scala
index fc833e2c26..7f627f7904 100644
--- a/src/compiler/scala/tools/nsc/settings/MutableSettings.scala
+++ b/src/compiler/scala/tools/nsc/settings/MutableSettings.scala
@@ -68,7 +68,7 @@ class MutableSettings(val errorFn: String => Unit)
if (isOpt) {
val newArgs = parseParams(args)
if (args eq newArgs) {
- errorFn("bad option: '" + x + "'")
+ errorFn(s"bad option: '$x'")
(false, args)
}
// discard empties, sometimes they appear because of ant or etc.
@@ -536,7 +536,7 @@ class MutableSettings(val errorFn: String => Unit)
}
override def tryToSetColon(args: List[String]) = tryToSet(args)
override def tryToSetFromPropertyValue(s: String) = tryToSet(s.trim.split(',').toList)
- def unparse: List[String] = value map { name + ":" + _ }
+ def unparse: List[String] = name :: value
withHelpSyntax(name + ":<" + arg + ">")
}
diff --git a/src/reflect/scala/reflect/internal/settings/MutableSettings.scala b/src/reflect/scala/reflect/internal/settings/MutableSettings.scala
index e9899f690d..96fd50646f 100644
--- a/src/reflect/scala/reflect/internal/settings/MutableSettings.scala
+++ b/src/reflect/scala/reflect/internal/settings/MutableSettings.scala
@@ -14,6 +14,7 @@ abstract class MutableSettings extends AbsSettings {
type Setting <: SettingValue
type BooleanSetting <: Setting { type T = Boolean }
type IntSetting <: Setting { type T = Int }
+ type MultiStringSetting <: Setting { type T = List[String] }
// basically this is a value which remembers if it's been modified
trait SettingValue extends AbsSettingValue {
@@ -46,4 +47,4 @@ abstract class MutableSettings extends AbsSettings {
def XoldPatmat: BooleanSetting
def XnoPatmatAnalysis: BooleanSetting
def XfullLubs: BooleanSetting
-} \ No newline at end of file
+}
diff --git a/src/reflect/scala/reflect/runtime/Settings.scala b/src/reflect/scala/reflect/runtime/Settings.scala
index eedb88320b..da4f4fbda1 100644
--- a/src/reflect/scala/reflect/runtime/Settings.scala
+++ b/src/reflect/scala/reflect/runtime/Settings.scala
@@ -1,11 +1,13 @@
package scala.reflect
package runtime
+import scala.reflect.internal.settings.MutableSettings
+
/** The Settings class for runtime reflection.
* This should be refined, so that settings are settable via command
* line options or properties.
*/
-class Settings extends internal.settings.MutableSettings {
+class Settings extends MutableSettings {
trait Setting extends SettingValue { }
@@ -21,20 +23,27 @@ class Settings extends internal.settings.MutableSettings {
override def value: Int = v
}
- val overrideObjects = new BooleanSetting(false)
- val debug = new BooleanSetting(false)
- val Ynotnull = new BooleanSetting(false)
- val explaintypes = new BooleanSetting(false)
- val verbose = new BooleanSetting(false)
- val uniqid = new BooleanSetting(false)
- val Yshowsymkinds = new BooleanSetting(false)
- val Xprintpos = new BooleanSetting(false)
- val printtypes = new BooleanSetting(false)
- val Yrecursion = new IntSetting(0)
- val maxClassfileName = new IntSetting(255)
- val Xexperimental = new BooleanSetting(false)
- val deepCloning = new BooleanSetting (false)
- val XoldPatmat = new BooleanSetting(false)
+ class MultiStringSetting(xs: List[String]) extends Setting {
+ type T = List[String]
+ protected var v: List[String] = xs
+ override def value: List[String] = v
+ }
+
+ val Xexperimental = new BooleanSetting(false)
+ val XfullLubs = new BooleanSetting(false)
val XnoPatmatAnalysis = new BooleanSetting(false)
- val XfullLubs = new BooleanSetting(false)
+ val XoldPatmat = new BooleanSetting(false)
+ val Xprintpos = new BooleanSetting(false)
+ val Ynotnull = new BooleanSetting(false)
+ val Yshowsymkinds = new BooleanSetting(false)
+ val debug = new BooleanSetting(false)
+ val deepCloning = new BooleanSetting(false)
+ val explaintypes = new BooleanSetting(false)
+ val overrideObjects = new BooleanSetting(false)
+ val printtypes = new BooleanSetting(false)
+ val uniqid = new BooleanSetting(false)
+ val verbose = new BooleanSetting(false)
+
+ val Yrecursion = new IntSetting(0)
+ val maxClassfileName = new IntSetting(255)
}