Skip to content

Remove unused flags #1987

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions compiler/src/dotty/tools/dotc/config/CompilerCommand.scala
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,20 @@ object CompilerCommand extends DotClass {

def shouldStopWithInfo = {
import settings._
Set(help, Xhelp, Yhelp, showPlugins, showPhases) exists (_.value)
Set(help, Xhelp, Yhelp) exists (_.value)
}

def infoMessage: String = {
import settings._
if (help.value) usageMessage
else if (Xhelp.value) xusageMessage
else if (Yhelp.value) yusageMessage
// else if (showPlugins.value) global.pluginDescriptions
// else if (showPhases.value) global.phaseDescriptions + (
// if (debug.value) "\n" + global.phaseFlagDescriptions else ""
// )
else ""
if (help.value) usageMessage
else if (Xhelp.value) xusageMessage
else if (Yhelp.value) yusageMessage
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")
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/config/PathResolver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
173 changes: 8 additions & 165 deletions compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

Large diffs are not rendered by default.

20 changes: 12 additions & 8 deletions compiler/src/dotty/tools/dotc/config/Settings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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] (
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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))
Expand All @@ -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 =>
Expand All @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions compiler/test/dotc/tests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,6 @@ class tests extends CompilerTest {

val negCustomArgs = negDir + "customArgs/"

@Test def neg_cli_error = compileFile(negCustomArgs, "cliError", List("-thisOptionDoesNotExist"))

@Test def neg_typers() = compileFile(negCustomArgs, "typers")(allowDoubleBindings)
@Test def neg_overrideClass = compileFile(negCustomArgs, "overrideClass", scala2mode)
@Test def neg_autoTupling = compileFile(negCustomArgs, "autoTuplingTest", args = "-language:noAutoTupling" :: Nil)
Expand Down
2 changes: 2 additions & 0 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ object DottyBuild extends Build {
dependsOn(`dotty-compiler`).
dependsOn(`dotty-library`).
settings(
triggeredMessage in ThisBuild := Watched.clearWhenTriggered,

addCommandAlias("run", "dotty-compiler/run") ++
addCommandAlias(
"partest",
Expand Down
1 change: 1 addition & 0 deletions sbt-bridge/test/xsbt/ScalaCompilerForUnitTesting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import ScalaCompilerForUnitTesting.ExtractedSourceDependencies
* source code using Scala compiler.
*/
class ScalaCompilerForUnitTesting(nameHashing: Boolean = false) {
import scala.language.reflectiveCalls

/**
* Compiles given source code using Scala compiler and returns API representation
Expand Down
2 changes: 0 additions & 2 deletions tests/neg/customArgs/cliError.scala

This file was deleted.