Skip to content

Commit f76ffe9

Browse files
authored
Merge pull request #1987 from dotty-staging/topic/remove-unused-flags
Remove unused flags
2 parents 8e2c271 + ae43a29 commit f76ffe9

File tree

8 files changed

+32
-187
lines changed

8 files changed

+32
-187
lines changed

compiler/src/dotty/tools/dotc/config/CompilerCommand.scala

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,21 +93,20 @@ object CompilerCommand extends DotClass {
9393

9494
def shouldStopWithInfo = {
9595
import settings._
96-
Set(help, Xhelp, Yhelp, showPlugins, showPhases) exists (_.value)
96+
Set(help, Xhelp, Yhelp) exists (_.value)
9797
}
9898

9999
def infoMessage: String = {
100100
import settings._
101-
if (help.value) usageMessage
102-
else if (Xhelp.value) xusageMessage
103-
else if (Yhelp.value) yusageMessage
104-
// else if (showPlugins.value) global.pluginDescriptions
105-
// else if (showPhases.value) global.phaseDescriptions + (
106-
// if (debug.value) "\n" + global.phaseFlagDescriptions else ""
107-
// )
108-
else ""
101+
if (help.value) usageMessage
102+
else if (Xhelp.value) xusageMessage
103+
else if (Yhelp.value) yusageMessage
104+
else ""
109105
}
110106

107+
// Print all warnings encountered during arguments parsing
108+
summary.warnings.foreach(ctx.warning(_))
109+
111110
if (summary.errors.nonEmpty) {
112111
summary.errors foreach (ctx.error(_))
113112
ctx.echo(" dotc -help gives more information")

compiler/src/dotty/tools/dotc/config/PathResolver.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ object PathResolver {
144144
}
145145
else {
146146
implicit val ctx = (new ContextBase).initialCtx
147-
val ArgsSummary(sstate, rest, errors) =
147+
val ArgsSummary(sstate, rest, errors, warnings) =
148148
ctx.settings.processArguments(args.toList, true)
149149
errors.foreach(println)
150150
val pr = new PathResolver()(ctx.fresh.setSettings(sstate))

compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

Lines changed: 8 additions & 165 deletions
Large diffs are not rendered by default.

compiler/src/dotty/tools/dotc/config/Settings.scala

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,14 @@ object Settings {
4444
case class ArgsSummary(
4545
sstate: SettingsState,
4646
arguments: List[String],
47-
errors: List[String]) {
47+
errors: List[String],
48+
warnings: List[String]) {
4849

4950
def fail(msg: String) =
50-
ArgsSummary(sstate, arguments, errors :+ msg)
51+
ArgsSummary(sstate, arguments.tail, errors :+ msg, warnings)
52+
53+
def warn(msg: String) =
54+
ArgsSummary(sstate, arguments.tail, errors, warnings :+ msg)
5155
}
5256

5357
case class Setting[T: ClassTag] private[Settings] (
@@ -106,11 +110,11 @@ object Settings {
106110
}
107111

108112
def tryToSet(state: ArgsSummary): ArgsSummary = {
109-
val ArgsSummary(sstate, arg :: args, errors) = state
113+
val ArgsSummary(sstate, arg :: args, errors, warnings) = state
110114
def update(value: Any, args: List[String]) =
111-
ArgsSummary(updateIn(sstate, value), args, errors)
115+
ArgsSummary(updateIn(sstate, value), args, errors, warnings)
112116
def fail(msg: String, args: List[String]) =
113-
ArgsSummary(sstate, args, errors :+ msg)
117+
ArgsSummary(sstate, args, errors :+ msg, warnings)
114118
def missingArg =
115119
fail(s"missing argument for option $name", args)
116120
def doSet(argRest: String) = ((implicitly[ClassTag[T]], args): @unchecked) match {
@@ -206,7 +210,7 @@ object Settings {
206210
* to get their arguments.
207211
*/
208212
protected def processArguments(state: ArgsSummary, processAll: Boolean, skipped: List[String]): ArgsSummary = {
209-
def stateWithArgs(args: List[String]) = ArgsSummary(state.sstate, args, state.errors)
213+
def stateWithArgs(args: List[String]) = ArgsSummary(state.sstate, args, state.errors, state.warnings)
210214
state.arguments match {
211215
case Nil =>
212216
checkDependencies(stateWithArgs(skipped))
@@ -219,7 +223,7 @@ object Settings {
219223
if (state1 ne state) processArguments(state1, processAll, skipped)
220224
else loop(settings1)
221225
case Nil =>
222-
state.fail(s"bad option: '$x'")
226+
processArguments(state.warn(s"bad option '$x' was ignored"), processAll, skipped)
223227
}
224228
loop(allSettings.toList)
225229
case arg :: args =>
@@ -229,7 +233,7 @@ object Settings {
229233
}
230234

231235
def processArguments(arguments: List[String], processAll: Boolean)(implicit ctx: Context): ArgsSummary =
232-
processArguments(ArgsSummary(ctx.sstate, arguments, Nil), processAll, Nil)
236+
processArguments(ArgsSummary(ctx.sstate, arguments, Nil, Nil), processAll, Nil)
233237

234238
def publish[T](settingf: Int => Setting[T]): Setting[T] = {
235239
val setting = settingf(_allSettings.length)

compiler/test/dotc/tests.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,6 @@ class tests extends CompilerTest {
179179

180180
val negCustomArgs = negDir + "customArgs/"
181181

182-
@Test def neg_cli_error = compileFile(negCustomArgs, "cliError", List("-thisOptionDoesNotExist"))
183-
184182
@Test def neg_typers() = compileFile(negCustomArgs, "typers")(allowDoubleBindings)
185183
@Test def neg_overrideClass = compileFile(negCustomArgs, "overrideClass", scala2mode)
186184
@Test def neg_autoTupling = compileFile(negCustomArgs, "autoTuplingTest", args = "-language:noAutoTupling" :: Nil)

project/Build.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ object DottyBuild extends Build {
131131
dependsOn(`dotty-compiler`).
132132
dependsOn(`dotty-library`).
133133
settings(
134+
triggeredMessage in ThisBuild := Watched.clearWhenTriggered,
135+
134136
addCommandAlias("run", "dotty-compiler/run") ++
135137
addCommandAlias(
136138
"partest",

sbt-bridge/test/xsbt/ScalaCompilerForUnitTesting.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import ScalaCompilerForUnitTesting.ExtractedSourceDependencies
2222
* source code using Scala compiler.
2323
*/
2424
class ScalaCompilerForUnitTesting(nameHashing: Boolean = false) {
25+
import scala.language.reflectiveCalls
2526

2627
/**
2728
* Compiles given source code using Scala compiler and returns API representation

tests/neg/customArgs/cliError.scala

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)