aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty
diff options
context:
space:
mode:
authorFelix Mulder <felix.mulder@gmail.com>2017-02-20 11:46:35 +0100
committerFelix Mulder <felix.mulder@gmail.com>2017-02-20 13:08:25 +0100
commitae43a298144842861bd8532b88aec7178c16ccb3 (patch)
tree763aa7881f4d71a562b27627d4e76df13b2416c5 /compiler/src/dotty
parent2f5b1f81bca206e7bfd684a41a2ade787ef2bc19 (diff)
downloaddotty-ae43a298144842861bd8532b88aec7178c16ccb3.tar.gz
dotty-ae43a298144842861bd8532b88aec7178c16ccb3.tar.bz2
dotty-ae43a298144842861bd8532b88aec7178c16ccb3.zip
Make non-existent compiler options emit warnings instead of failing
Diffstat (limited to 'compiler/src/dotty')
-rw-r--r--compiler/src/dotty/tools/dotc/config/CompilerCommand.scala3
-rw-r--r--compiler/src/dotty/tools/dotc/config/PathResolver.scala2
-rw-r--r--compiler/src/dotty/tools/dotc/config/ScalaSettings.scala2
-rw-r--r--compiler/src/dotty/tools/dotc/config/Settings.scala20
4 files changed, 16 insertions, 11 deletions
diff --git a/compiler/src/dotty/tools/dotc/config/CompilerCommand.scala b/compiler/src/dotty/tools/dotc/config/CompilerCommand.scala
index 6e0c60555..c2301a3aa 100644
--- a/compiler/src/dotty/tools/dotc/config/CompilerCommand.scala
+++ b/compiler/src/dotty/tools/dotc/config/CompilerCommand.scala
@@ -104,6 +104,9 @@ object CompilerCommand extends DotClass {
else ""
}
+ // Print all warnings encountered during arguments parsing
+ summary.warnings.foreach(ctx.warning(_))
+
if (summary.errors.nonEmpty) {
summary.errors foreach (ctx.error(_))
ctx.echo(" dotc -help gives more information")
diff --git a/compiler/src/dotty/tools/dotc/config/PathResolver.scala b/compiler/src/dotty/tools/dotc/config/PathResolver.scala
index 184b3718a..159989e6f 100644
--- a/compiler/src/dotty/tools/dotc/config/PathResolver.scala
+++ b/compiler/src/dotty/tools/dotc/config/PathResolver.scala
@@ -144,7 +144,7 @@ object PathResolver {
}
else {
implicit val ctx = (new ContextBase).initialCtx
- val ArgsSummary(sstate, rest, errors) =
+ val ArgsSummary(sstate, rest, errors, warnings) =
ctx.settings.processArguments(args.toList, true)
errors.foreach(println)
val pr = new PathResolver()(ctx.fresh.setSettings(sstate))
diff --git a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala
index 9aac7836c..fd79fcaa6 100644
--- a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala
+++ b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala
@@ -26,8 +26,6 @@ class ScalaSettings extends Settings.SettingGroup {
val explain = BooleanSetting("-explain", "Explain errors in more detail.")
val feature = BooleanSetting("-feature", "Emit warning and location for usages of features that should be imported explicitly.")
val help = BooleanSetting("-help", "Print a synopsis of standard options")
- // FIXME: `-nowarn` is not used in the compiler, but sbt passes this as an option
- val nowarn = BooleanSetting("-nowarn", "Generate no warnings.")
val color = ChoiceSetting("-color", "mode", "Colored output", List("always", "never"/*, "auto"*/), "always"/* "auto"*/)
val target = ChoiceSetting("-target", "target", "Target platform for object files. All JVM 1.5 targets are deprecated.",
List("jvm-1.5", "jvm-1.5-fjbg", "jvm-1.5-asm", "jvm-1.6", "jvm-1.7", "jvm-1.8", "msil"), "jvm-1.8")
diff --git a/compiler/src/dotty/tools/dotc/config/Settings.scala b/compiler/src/dotty/tools/dotc/config/Settings.scala
index cffa047fe..58fa6d366 100644
--- a/compiler/src/dotty/tools/dotc/config/Settings.scala
+++ b/compiler/src/dotty/tools/dotc/config/Settings.scala
@@ -44,10 +44,14 @@ object Settings {
case class ArgsSummary(
sstate: SettingsState,
arguments: List[String],
- errors: List[String]) {
+ errors: List[String],
+ warnings: List[String]) {
def fail(msg: String) =
- ArgsSummary(sstate, arguments, errors :+ msg)
+ ArgsSummary(sstate, arguments.tail, errors :+ msg, warnings)
+
+ def warn(msg: String) =
+ ArgsSummary(sstate, arguments.tail, errors, warnings :+ msg)
}
case class Setting[T: ClassTag] private[Settings] (
@@ -106,11 +110,11 @@ object Settings {
}
def tryToSet(state: ArgsSummary): ArgsSummary = {
- val ArgsSummary(sstate, arg :: args, errors) = state
+ val ArgsSummary(sstate, arg :: args, errors, warnings) = state
def update(value: Any, args: List[String]) =
- ArgsSummary(updateIn(sstate, value), args, errors)
+ ArgsSummary(updateIn(sstate, value), args, errors, warnings)
def fail(msg: String, args: List[String]) =
- ArgsSummary(sstate, args, errors :+ msg)
+ ArgsSummary(sstate, args, errors :+ msg, warnings)
def missingArg =
fail(s"missing argument for option $name", args)
def doSet(argRest: String) = ((implicitly[ClassTag[T]], args): @unchecked) match {
@@ -206,7 +210,7 @@ object Settings {
* to get their arguments.
*/
protected def processArguments(state: ArgsSummary, processAll: Boolean, skipped: List[String]): ArgsSummary = {
- def stateWithArgs(args: List[String]) = ArgsSummary(state.sstate, args, state.errors)
+ def stateWithArgs(args: List[String]) = ArgsSummary(state.sstate, args, state.errors, state.warnings)
state.arguments match {
case Nil =>
checkDependencies(stateWithArgs(skipped))
@@ -219,7 +223,7 @@ object Settings {
if (state1 ne state) processArguments(state1, processAll, skipped)
else loop(settings1)
case Nil =>
- state.fail(s"bad option: '$x'")
+ processArguments(state.warn(s"bad option '$x' was ignored"), processAll, skipped)
}
loop(allSettings.toList)
case arg :: args =>
@@ -229,7 +233,7 @@ object Settings {
}
def processArguments(arguments: List[String], processAll: Boolean)(implicit ctx: Context): ArgsSummary =
- processArguments(ArgsSummary(ctx.sstate, arguments, Nil), processAll, Nil)
+ processArguments(ArgsSummary(ctx.sstate, arguments, Nil, Nil), processAll, Nil)
def publish[T](settingf: Int => Setting[T]): Setting[T] = {
val setting = settingf(_allSettings.length)