diff --git a/src/compiler/scala/tools/nsc/settings/FscSettings.scala b/src/compiler/scala/tools/nsc/settings/FscSettings.scala index a016861b3a..7b4569ed42 100644 --- a/src/compiler/scala/tools/nsc/settings/FscSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/FscSettings.scala @@ -61,7 +61,7 @@ class FscSettings(error: String => Unit, pathFactory: PathFactory = DefaultPathF /** All user set settings rewritten with absolute paths based on currentDir */ def absolutize() { userSetSettings foreach { - case p: OutputSetting => p.outputDirs setSingleOutput AbstractFile.getDirectory(absolutizePath(p.value)) + case p: OutputSetting => outputDirs.setSingleOutput(AbstractFile.getDirectory(absolutizePath(p.value))) case p: PathSetting => p.value = ClassPath.map(p.value, absolutizePath) case p: StringSetting => if (holdsPath(p)) p.value = absolutizePath(p.value) case _ => () diff --git a/src/compiler/scala/tools/nsc/settings/MutableSettings.scala b/src/compiler/scala/tools/nsc/settings/MutableSettings.scala index c27204d97b..dbdd8026cb 100644 --- a/src/compiler/scala/tools/nsc/settings/MutableSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/MutableSettings.scala @@ -102,11 +102,11 @@ class MutableSettings(val errorFn: String => Unit, val pathFactory: PathFactory) s } - /** A list pairing source directories with their output directory. - * This option is not available on the command line, but can be set by - * other tools (IDEs especially). The command line specifies a single - * output directory that is used for all source files, denoted by a - * '*' in this list. + /** A list pairing source directories with their respective output directory. + * + * Tools may set outputDirs programmatically. + * + * The `-d` commandline option sets a single directory for all sources. */ lazy val outputDirs = new OutputDirs @@ -227,7 +227,7 @@ class MutableSettings(val errorFn: String => Unit, val pathFactory: PathFactory) s } - def BooleanSetting(name: String, descr: String) = add(new BooleanSetting(name, descr)) + def BooleanSetting(name: String, descr: String, default: Boolean = false) = add(new BooleanSetting(name, descr, default)) def ChoiceSetting(name: String, helpArg: String, descr: String, choices: List[String], default: String, choicesHelp: List[String] = Nil) = add(new ChoiceSetting(name, helpArg, descr, choices, default, choicesHelp)) def ChoiceSettingForcedDefault(name: String, helpArg: String, descr: String, choices: List[String], default: String, choicesHelp: List[String] = Nil) = @@ -239,11 +239,11 @@ class MutableSettings(val errorFn: String => Unit, val pathFactory: PathFactory) ) def IntSetting(name: String, descr: String, default: Int, range: Option[(Int, Int)], parser: String => Option[Int]) = add(new IntSetting(name, descr, default, range, parser)) - def MultiStringSetting(name: String, arg: String, descr: String, helpText: Option[String] = None, prepend: Boolean = false) = - add(new MultiStringSetting(name, arg, descr, helpText, prepend)) + def MultiStringSetting(name: String, arg: String, descr: String, default: List[String] = Nil, helpText: Option[String] = None, prepend: Boolean = false) = + add(new MultiStringSetting(name, arg, descr, default, helpText, prepend)) def MultiChoiceSetting[E <: MultiChoiceEnumeration](name: String, helpArg: String, descr: String, domain: E, default: Option[List[String]] = None) = add(new MultiChoiceSetting[E](name, helpArg, descr, domain, default)) - def OutputSetting(outputDirs: OutputDirs, default: String) = add(new OutputSetting(outputDirs, default)) + def OutputSetting(outputDirs: OutputDirs, default: String) = { outputDirs.setSingleOutput(default); add(new OutputSetting(default)) } def PhasesSetting(name: String, descr: String, default: String = "") = add(new PhasesSetting(name, descr, default)) def StringSetting(name: String, arg: String, descr: String, default: String, helpText: Option[String] = None) = add(new StringSetting(name, arg, descr, default, helpText)) def ScalaVersionSetting(name: String, arg: String, descr: String, initial: ScalaVersion, default: Option[ScalaVersion] = None) = @@ -279,14 +279,10 @@ class MutableSettings(val errorFn: String => Unit, val pathFactory: PathFactory) checkDir(pathFactory.getDirectory(outDir), outDir)) /** Check that dir is exists and is a directory. */ - private def checkDir(dir: AbstractFile, name: String, allowJar: Boolean = false): AbstractFile = ( - if (dir != null && dir.isDirectory) - dir - else if (allowJar && dir == null && Jar.isJarOrZip(name, examineFile = false)) - new PlainFile(Path(name)) - else - throw new FatalError(name + " does not exist or is not a directory") - ) + private def checkDir(dir: AbstractFile, name: String, allowJar: Boolean = false): AbstractFile = + if (dir != null && dir.isDirectory) dir + else if (allowJar && dir == null && Jar.isJarOrZip(name, examineFile = false)) new PlainFile(Path(name)) + else throw new FatalError(s"$name does not exist or is not a directory") /** Set the single output directory. From now on, all files will * be dumped in there, regardless of previous calls to 'add'. @@ -301,9 +297,7 @@ class MutableSettings(val errorFn: String => Unit, val pathFactory: PathFactory) /** Set the single output directory. From now on, all files will * be dumped in there, regardless of previous calls to 'add'. */ - def setSingleOutput(dir: AbstractFile) { - singleOutDir = Some(dir) - } + def setSingleOutput(dir: AbstractFile): Unit = singleOutDir = Some(dir) def add(src: AbstractFile, dst: AbstractFile) { singleOutDir = None @@ -316,16 +310,12 @@ class MutableSettings(val errorFn: String => Unit, val pathFactory: PathFactory) /** Return the output directory for the given file. */ def outputDirFor(src: AbstractFile): AbstractFile = { - def isBelow(srcDir: AbstractFile, outDir: AbstractFile) = - src.path.startsWith(srcDir.path) + def isBelow(srcDir: AbstractFile, outDir: AbstractFile) = src.path.startsWith(srcDir.path) singleOutDir.getOrElse(outputs.find((isBelow _).tupled) match { - case Some((_, d)) => d - case _ => - throw new FatalError("Could not find an output directory for " - + src.path + " in " + outputs) - } - ) + case Some((_, d)) => d + case _ => throw new FatalError(s"Could not find an output directory for ${src.path} in ${outputs}") + }) } /** Return the source file path(s) which correspond to the given @@ -346,8 +336,7 @@ class MutableSettings(val errorFn: String => Unit, val pathFactory: PathFactory) * paths. */ def srcFilesFor(classFile : AbstractFile, srcPath : String) : List[AbstractFile] = { - def isBelow(srcDir: AbstractFile, outDir: AbstractFile) = - classFile.path.startsWith(outDir.path) + def isBelow(srcDir: AbstractFile, outDir: AbstractFile) = classFile.path.startsWith(outDir.path) singleOutDir match { case Some(d) => @@ -368,7 +357,6 @@ class MutableSettings(val errorFn: String => Unit, val pathFactory: PathFactory) * Subclasses each define a `value` field of the appropriate type. */ abstract class Setting(val name: String, val helpDescription: String) extends AbsSetting with SettingValue with Mutable { - def withDefault(value: T): this.type = { v = value; this } /** Will be called after this Setting is set for any extra work. */ private var _postSetHook: this.type => Unit = (x: this.type) => () @@ -456,20 +444,16 @@ class MutableSettings(val errorFn: String => Unit, val pathFactory: PathFactory) withHelpSyntax(s"$name ") } - /** A setting represented by a boolean flag (false, unless set) */ - class BooleanSetting private[nsc]( - name: String, - descr: String) - extends Setting(name, descr) { + /** A setting that is a boolean flag, with default as specified. */ + class BooleanSetting private[nsc](name: String, descr: String, default: Boolean) extends Setting(name, s"$descr [$default]") { type T = Boolean - protected var v: Boolean = false + protected var v: Boolean = default override def value: Boolean = v def tryToSet(args: List[String]) = { value = true ; Some(args) } def unparse: List[String] = if (value) List(name) else Nil - override def tryToSetFromPropertyValue(s : String) { // used from ide - value = s.equalsIgnoreCase("true") - } + // used from ide + override def tryToSetFromPropertyValue(s : String): Unit = value = s.equalsIgnoreCase("true") override def tryToSetColon(args: List[String]) = args match { case Nil => tryToSet(Nil) case List(x) => @@ -587,18 +571,8 @@ class MutableSettings(val errorFn: String => Unit, val pathFactory: PathFactory) ) } - /** Set the output directory. */ - class OutputSetting private[nsc]( - private[nsc] val outputDirs: OutputDirs, - default: String) - extends StringSetting("-d", "directory|jar", "destination for generated classfiles.", default, None) { - value = default - override def value_=(str: String) { - super.value_=(str) - try outputDirs.setSingleOutput(str) - catch { case FatalError(msg) => errorFn(msg) } - } - } + /** Set the output directory for all sources. */ + class OutputSetting private[nsc](default: String) extends StringSetting("-d", "directory|jar", "destination for generated classfiles.", default, None) /** * Each [[MultiChoiceSetting]] takes a MultiChoiceEnumeration as domain. The enumeration may @@ -810,11 +784,12 @@ class MutableSettings(val errorFn: String => Unit, val pathFactory: PathFactory) name: String, val arg: String, descr: String, + default: List[String], helpText: Option[String], prepend: Boolean) extends Setting(name, descr) with Clearable { type T = List[String] - protected var v: T = Nil + protected var v: T = default protected var sawHelp: Boolean = false withHelpSyntax(name + ":<" + arg + ">") @@ -858,8 +833,9 @@ class MutableSettings(val errorFn: String => Unit, val pathFactory: PathFactory) val default: String, val choicesHelp: List[String]) extends Setting(name, - if (choicesHelp.isEmpty) s"$descr Choices: ${choices.mkString("(", ",", ")")}, default: $default." - else s"$descr Default: `$default', `help' to list choices.") { + if (choicesHelp.isEmpty) s"$descr ${choices.map(s => if (s == default) s"[$s]" else s).mkString("(", ",", ")")}" + else s"$descr Default: `$default`, `help` to list choices." + ) { type T = String protected var v: T = default def indexOfChoice: Int = choices indexOf value diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala index 2d3dc5b720..e2598d1c0b 100644 --- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala @@ -26,6 +26,7 @@ import scala.collection.mutable import scala.tools.nsc.util.DefaultJarFactory trait ScalaSettings extends StandardScalaSettings with Warnings { _: MutableSettings => + /** Set of settings */ protected[scala] lazy val allSettings = mutable.LinkedHashMap[String, Setting]() @@ -59,10 +60,11 @@ trait ScalaSettings extends StandardScalaSettings with Warnings { _: MutableSett * Standard settings */ // argfiles is only for the help message - /*val argfiles = */ BooleanSetting ("@", "A text file containing compiler arguments (options and source files)") - val classpath = PathSetting ("-classpath", "Specify where to find user class files.", defaultClasspath) withAbbreviation "-cp" - val d = OutputSetting (outputDirs, ".") - val nospecialization = BooleanSetting ("-no-specialization", "Ignore @specialize annotations.") + /*val argfiles = */ BooleanSetting("@", "A text file containing compiler arguments (options and source files)") + val classpath = PathSetting ("-classpath", "Specify where to find user class files.", defaultClasspath) withAbbreviation "-cp" + val d = OutputSetting (outputDirs, ".").withPostSetHook(s => try outputDirs.setSingleOutput(s.value) catch { case FatalError(msg) => errorFn(msg) }) + + val nospecialization = BooleanSetting("-no-specialization", "Ignore @specialize annotations.") // Would be nice to build this dynamically from scala.languageFeature. // The two requirements: delay error checking until you have symbols, and let compiler command build option-specific help. @@ -259,7 +261,7 @@ trait ScalaSettings extends StandardScalaSettings with Warnings { _: MutableSett val YpickleJava = BooleanSetting("-Ypickle-java", "Pickler phase should compute pickles for .java defined symbols for use by build tools").internalOnly() val YpickleWrite = StringSetting("-Ypickle-write", "directory|jar", "destination for generated .sig files containing type signatures.", "", None).internalOnly() val YpickleWriteApiOnly = BooleanSetting("-Ypickle-write-api-only", "Exclude private members (other than those material to subclass compilation, such as private trait vals) from generated .sig files containing type signatures.").internalOnly() - val YtrackDependencies = BooleanSetting("-Ytrack-dependencies", "Record references to in unit.depends. Deprecated feature that supports SBT 0.13 with incOptions.withNameHashing(false) only.").withDefault(true) + val YtrackDependencies = BooleanSetting("-Ytrack-dependencies", "Record references to in unit.depends. Deprecated feature that supports SBT 0.13 with incOptions.withNameHashing(false) only.", default = true) sealed abstract class CachePolicy(val name: String, val help: String) object CachePolicy { diff --git a/src/compiler/scala/tools/nsc/settings/Warnings.scala b/src/compiler/scala/tools/nsc/settings/Warnings.scala index 0e7537441e..d54382b154 100644 --- a/src/compiler/scala/tools/nsc/settings/Warnings.scala +++ b/src/compiler/scala/tools/nsc/settings/Warnings.scala @@ -31,6 +31,7 @@ trait Warnings { "-Wconf", "patterns", "Configure reporting of compiler warnings; use `help` for details.", + default = WconfDefault, helpText = Some( s"""Configure compiler warnings. |Syntax: -Wconf::,:,... @@ -93,7 +94,6 @@ trait Warnings { |Note: on the command-line you might need to quote configurations containing `*` or `&` |to prevent the shell from expanding patterns.""".stripMargin), prepend = true) - locally { Wconf.tryToSet(WconfDefault); Wconf.clearSetByUser() } // Non-lint warnings. -- TODO turn into MultiChoiceEnumeration val warnMacros = ChoiceSetting( @@ -155,11 +155,7 @@ trait Warnings { // They are not activated by -Xlint and can't be enabled on the command line because they are not // created using the standard factory methods. - val warnValueOverrides = { - val flag = new BooleanSetting("value-overrides", "Generated value class method overrides an implementation.") - flag.value = false - flag - } + val warnValueOverrides = new BooleanSetting("value-overrides", "Generated value class method overrides an implementation.", default = false) // Lint warnings diff --git a/src/reflect/scala/reflect/internal/settings/MutableSettings.scala b/src/reflect/scala/reflect/internal/settings/MutableSettings.scala index 50c8a43fe2..6d50c6ab41 100644 --- a/src/reflect/scala/reflect/internal/settings/MutableSettings.scala +++ b/src/reflect/scala/reflect/internal/settings/MutableSettings.scala @@ -33,7 +33,6 @@ abstract class MutableSettings extends AbsSettings { def postSetHook(): Unit = () def isDefault = !setByUser def isSetByUser = setByUser - private[scala] def clearSetByUser(): Unit = setByUser = false def value: T = v def value_=(arg: T) = { setByUser = true diff --git a/test/files/run/settings-parse.check b/test/files/run/settings-parse.check index 476c7f45ff..03c363b551 100644 --- a/test/files/run/settings-parse.check +++ b/test/files/run/settings-parse.check @@ -1,642 +1,544 @@ 0) List(-cp, ) ==> Settings { -classpath = "" - -d = . } 1) List(-cp, , ) ==> Settings { -classpath = "" - -d = . } 2) List(, -cp, ) ==> Settings { -classpath = "" - -d = . } 3) List(-cp, , -deprecation) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = "" - -d = . } 4) List(-cp, , , -deprecation) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = "" - -d = . } 5) List(-cp, , -deprecation, ) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = "" - -d = . } 6) List(, -cp, , -deprecation) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = "" - -d = . } 7) List(-cp, , -deprecation, foo.scala) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = "" - -d = . } 8) List(-cp, , , -deprecation, foo.scala) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = "" - -d = . } 9) List(-cp, , -deprecation, , foo.scala) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = "" - -d = . } 10) List(-cp, , -deprecation, foo.scala, ) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = "" - -d = . } 11) List(, -cp, , -deprecation, foo.scala) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = "" - -d = . } 12) List(-cp, , foo.scala) ==> Settings { -classpath = "" - -d = . } 13) List(-cp, , , foo.scala) ==> Settings { -classpath = "" - -d = . } 14) List(-cp, , foo.scala, ) ==> Settings { -classpath = "" - -d = . } 15) List(, -cp, , foo.scala) ==> Settings { -classpath = "" - -d = . } 16) List(-cp, , foo.scala, -deprecation) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = "" - -d = . } 17) List(-cp, , , foo.scala, -deprecation) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = "" - -d = . } 18) List(-cp, , foo.scala, , -deprecation) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = "" - -d = . } 19) List(-cp, , foo.scala, -deprecation, ) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = "" - -d = . } 20) List(, -cp, , foo.scala, -deprecation) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = "" - -d = . } 21) List(-deprecation, -cp, ) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = "" - -d = . } 22) List(, -deprecation, -cp, ) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = "" - -d = . } 23) List(-deprecation, -cp, , ) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = "" - -d = . } 24) List(-deprecation, , -cp, ) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = "" - -d = . } 25) List(-deprecation, -cp, , foo.scala) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = "" - -d = . } 26) List(, -deprecation, -cp, , foo.scala) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = "" - -d = . } 27) List(-deprecation, -cp, , , foo.scala) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = "" - -d = . } 28) List(-deprecation, -cp, , foo.scala, ) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = "" - -d = . } 29) List(-deprecation, , -cp, , foo.scala) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = "" - -d = . } 30) List(-deprecation, foo.scala, -cp, ) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = "" - -d = . } 31) List(, -deprecation, foo.scala, -cp, ) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = "" - -d = . } 32) List(-deprecation, , foo.scala, -cp, ) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = "" - -d = . } 33) List(-deprecation, foo.scala, -cp, , ) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = "" - -d = . } 34) List(-deprecation, foo.scala, , -cp, ) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = "" - -d = . } 35) List(foo.scala, -cp, ) ==> Settings { -classpath = "" - -d = . } 36) List(, foo.scala, -cp, ) ==> Settings { -classpath = "" - -d = . } 37) List(foo.scala, -cp, , ) ==> Settings { -classpath = "" - -d = . } 38) List(foo.scala, , -cp, ) ==> Settings { -classpath = "" - -d = . } 39) List(foo.scala, -cp, , -deprecation) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = "" - -d = . } 40) List(, foo.scala, -cp, , -deprecation) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = "" - -d = . } 41) List(foo.scala, -cp, , , -deprecation) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = "" - -d = . } 42) List(foo.scala, -cp, , -deprecation, ) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = "" - -d = . } 43) List(foo.scala, , -cp, , -deprecation) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = "" - -d = . } 44) List(foo.scala, -deprecation, -cp, ) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = "" - -d = . } 45) List(, foo.scala, -deprecation, -cp, ) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = "" - -d = . } 46) List(foo.scala, , -deprecation, -cp, ) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = "" - -d = . } 47) List(foo.scala, -deprecation, -cp, , ) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = "" - -d = . } 48) List(foo.scala, -deprecation, , -cp, ) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = "" - -d = . } 0) List(-cp, /tmp:/bippy) ==> Settings { -classpath = /tmp:/bippy - -d = . } 1) List(-cp, /tmp:/bippy, ) ==> Settings { -classpath = /tmp:/bippy - -d = . } 2) List(, -cp, /tmp:/bippy) ==> Settings { -classpath = /tmp:/bippy - -d = . } 3) List(-cp, /tmp:/bippy, -deprecation) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = /tmp:/bippy - -d = . } 4) List(-cp, /tmp:/bippy, , -deprecation) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = /tmp:/bippy - -d = . } 5) List(-cp, /tmp:/bippy, -deprecation, ) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = /tmp:/bippy - -d = . } 6) List(, -cp, /tmp:/bippy, -deprecation) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = /tmp:/bippy - -d = . } 7) List(-cp, /tmp:/bippy, -deprecation, foo.scala) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = /tmp:/bippy - -d = . } 8) List(-cp, /tmp:/bippy, , -deprecation, foo.scala) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = /tmp:/bippy - -d = . } 9) List(-cp, /tmp:/bippy, -deprecation, , foo.scala) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = /tmp:/bippy - -d = . } 10) List(-cp, /tmp:/bippy, -deprecation, foo.scala, ) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = /tmp:/bippy - -d = . } 11) List(, -cp, /tmp:/bippy, -deprecation, foo.scala) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = /tmp:/bippy - -d = . } 12) List(-cp, /tmp:/bippy, foo.scala) ==> Settings { -classpath = /tmp:/bippy - -d = . } 13) List(-cp, /tmp:/bippy, , foo.scala) ==> Settings { -classpath = /tmp:/bippy - -d = . } 14) List(-cp, /tmp:/bippy, foo.scala, ) ==> Settings { -classpath = /tmp:/bippy - -d = . } 15) List(, -cp, /tmp:/bippy, foo.scala) ==> Settings { -classpath = /tmp:/bippy - -d = . } 16) List(-cp, /tmp:/bippy, foo.scala, -deprecation) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = /tmp:/bippy - -d = . } 17) List(-cp, /tmp:/bippy, , foo.scala, -deprecation) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = /tmp:/bippy - -d = . } 18) List(-cp, /tmp:/bippy, foo.scala, , -deprecation) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = /tmp:/bippy - -d = . } 19) List(-cp, /tmp:/bippy, foo.scala, -deprecation, ) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = /tmp:/bippy - -d = . } 20) List(, -cp, /tmp:/bippy, foo.scala, -deprecation) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = /tmp:/bippy - -d = . } 21) List(-deprecation, -cp, /tmp:/bippy) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = /tmp:/bippy - -d = . } 22) List(, -deprecation, -cp, /tmp:/bippy) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = /tmp:/bippy - -d = . } 23) List(-deprecation, -cp, /tmp:/bippy, ) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = /tmp:/bippy - -d = . } 24) List(-deprecation, , -cp, /tmp:/bippy) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = /tmp:/bippy - -d = . } 25) List(-deprecation, -cp, /tmp:/bippy, foo.scala) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = /tmp:/bippy - -d = . } 26) List(, -deprecation, -cp, /tmp:/bippy, foo.scala) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = /tmp:/bippy - -d = . } 27) List(-deprecation, -cp, /tmp:/bippy, , foo.scala) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = /tmp:/bippy - -d = . } 28) List(-deprecation, -cp, /tmp:/bippy, foo.scala, ) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = /tmp:/bippy - -d = . } 29) List(-deprecation, , -cp, /tmp:/bippy, foo.scala) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = /tmp:/bippy - -d = . } 30) List(-deprecation, foo.scala, -cp, /tmp:/bippy) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = /tmp:/bippy - -d = . } 31) List(, -deprecation, foo.scala, -cp, /tmp:/bippy) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = /tmp:/bippy - -d = . } 32) List(-deprecation, , foo.scala, -cp, /tmp:/bippy) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = /tmp:/bippy - -d = . } 33) List(-deprecation, foo.scala, -cp, /tmp:/bippy, ) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = /tmp:/bippy - -d = . } 34) List(-deprecation, foo.scala, , -cp, /tmp:/bippy) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = /tmp:/bippy - -d = . } 35) List(foo.scala, -cp, /tmp:/bippy) ==> Settings { -classpath = /tmp:/bippy - -d = . } 36) List(, foo.scala, -cp, /tmp:/bippy) ==> Settings { -classpath = /tmp:/bippy - -d = . } 37) List(foo.scala, -cp, /tmp:/bippy, ) ==> Settings { -classpath = /tmp:/bippy - -d = . } 38) List(foo.scala, , -cp, /tmp:/bippy) ==> Settings { -classpath = /tmp:/bippy - -d = . } 39) List(foo.scala, -cp, /tmp:/bippy, -deprecation) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = /tmp:/bippy - -d = . } 40) List(, foo.scala, -cp, /tmp:/bippy, -deprecation) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = /tmp:/bippy - -d = . } 41) List(foo.scala, -cp, /tmp:/bippy, , -deprecation) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = /tmp:/bippy - -d = . } 42) List(foo.scala, -cp, /tmp:/bippy, -deprecation, ) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = /tmp:/bippy - -d = . } 43) List(foo.scala, , -cp, /tmp:/bippy, -deprecation) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = /tmp:/bippy - -d = . } 44) List(foo.scala, -deprecation, -cp, /tmp:/bippy) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = /tmp:/bippy - -d = . } 45) List(, foo.scala, -deprecation, -cp, /tmp:/bippy) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = /tmp:/bippy - -d = . } 46) List(foo.scala, , -deprecation, -cp, /tmp:/bippy) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = /tmp:/bippy - -d = . } 47) List(foo.scala, -deprecation, -cp, /tmp:/bippy, ) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = /tmp:/bippy - -d = . } 48) List(foo.scala, -deprecation, , -cp, /tmp:/bippy) ==> Settings { -deprecation = true -Wconf = List(cat=deprecation:w, cat=deprecation:ws, cat=feature:ws, cat=optimizer:ws) -classpath = /tmp:/bippy - -d = . } diff --git a/test/files/run/settings-parse.scala b/test/files/run/settings-parse.scala index 8d83caf68f..0697e932fa 100644 --- a/test/files/run/settings-parse.scala +++ b/test/files/run/settings-parse.scala @@ -1,20 +1,20 @@ -import scala.language.postfixOps -import scala.tools.nsc._ +import scala.tools.nsc.settings.MutableSettings object Test { val tokens = "" :: "-deprecation" :: "foo.scala" :: Nil val permutations0 = tokens.toSet.subsets.flatMap(_.toList.permutations).toList.distinct def runWithCp(cp: String) = { - val permutations = permutations0 flatMap ("-cp CPTOKEN" :: _ permutations) + val permutations = permutations0.flatMap(s => ("-cp CPTOKEN" :: s).permutations) for ((p, i) <- permutations.distinct.sortBy(_ mkString "").zipWithIndex) { - val args = p flatMap (_ split "\\s+") map (x => if (x == "CPTOKEN") cp else x) - val s = new settings.MutableSettings(println) + val args = p.flatMap(_.split("\\s+")).map(x => if (x == "CPTOKEN") cp else x) + val expected = args.filter(_ == "foo.scala") + + val s = new MutableSettings(println) val (ok, residual) = s.processArguments(args, processAll = true) - val expected = args filter (_ == "foo.scala") assert(residual == expected, residual) assert(ok, args) println(s"$i) $args ==> $s") diff --git a/test/junit/scala/tools/nsc/settings/SettingsTest.scala b/test/junit/scala/tools/nsc/settings/SettingsTest.scala index e81d120d30..6c0335d882 100644 --- a/test/junit/scala/tools/nsc/settings/SettingsTest.scala +++ b/test/junit/scala/tools/nsc/settings/SettingsTest.scala @@ -12,7 +12,7 @@ class SettingsTest { @Test def booleanSettingColon() { def check(args: String*): MutableSettings#BooleanSetting = { val s = new MutableSettings(msg => throw new IllegalArgumentException(msg)) - val b1 = new s.BooleanSetting("-Ytest-setting", "") + val b1 = new s.BooleanSetting("-Ytest-setting", descr="", default=false) s.allSettings(b1.name) = b1 val (ok, residual) = s.processArguments(args.toList, processAll = true) assert(residual.isEmpty)