Skip to content

Clean up settings #10655

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 7 commits into from
Dec 10, 2020
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
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/Compiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class Compiler {
def newRun(using Context): Run = {
reset()
val rctx =
if ctx.settings.Ysemanticdb.value then
if ctx.settings.Xsemanticdb.value then
ctx.addMode(Mode.ReadPositions)
else
ctx
Expand Down
11 changes: 3 additions & 8 deletions compiler/src/dotty/tools/dotc/config/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ trait CommonScalaSettings { self: Settings.SettingGroup =>
val classpath: Setting[String] = PathSetting("-classpath", "Specify where to find user class files.", defaultClasspath) withAbbreviation "-cp" withAbbreviation "--class-path"
val outputDir: Setting[AbstractFile] = OutputSetting("-d", "directory|jar", "Destination for generated classfiles.",
new PlainDirectory(Directory(".")))
val priorityclasspath: Setting[String] = PathSetting("-priorityclasspath", "Class path that takes precedence over all other paths (or testing only).", "") withAbbreviation "--priority-class-path"
val priorityclasspath: Setting[String] = PathSetting("-priorityclasspath", "Class path that takes precedence over all other paths (for testing only).", "") withAbbreviation "--priority-class-path"
val color: Setting[String] = ChoiceSetting("-color", "mode", "Colored output", List("always", "never"/*, "auto"*/), "always"/* "auto"*/) withAbbreviation "--color"
val verbose: Setting[Boolean] = BooleanSetting("-verbose", "Output messages about what the compiler is doing.") withAbbreviation "--verbose"
val version: Setting[Boolean] = BooleanSetting("-version", "Print product version and exit.") withAbbreviation "--version"
Expand Down Expand Up @@ -92,7 +92,7 @@ class ScalaSettings extends Settings.SettingGroup with CommonScalaSettings {

val newSyntax: Setting[Boolean] = BooleanSetting("-new-syntax", "Require `then` and `do` in control expressions.")
val oldSyntax: Setting[Boolean] = BooleanSetting("-old-syntax", "Require `(...)` around conditions.")
val indent: Setting[Boolean] = BooleanSetting("-indent", "Allow significant indentation.")
val indent: Setting[Boolean] = BooleanSetting("-indent", "Together with -rewrite, remove {...} syntax when possible due to significant indentation.")
val noindent: Setting[Boolean] = BooleanSetting("-noindent", "Require classical {...} syntax, indentation is not significant.")
val YindentColons: Setting[Boolean] = BooleanSetting("-Yindent-colons", "Allow colons at ends-of-lines to start indentation blocks.")

Expand All @@ -118,12 +118,12 @@ class ScalaSettings extends Settings.SettingGroup with CommonScalaSettings {
val XprintSuspension: Setting[Boolean] = BooleanSetting("-Xprint-suspension", "Show when code is suspended until macros are compiled.")
val Xprompt: Setting[Boolean] = BooleanSetting("-Xprompt", "Display a prompt after each error (debugging option).")
val XshowPhases: Setting[Boolean] = BooleanSetting("-Xshow-phases", "Print all compiler phases.")
val XreplLineWidth: Setting[Int] = IntSetting("-Xrepl-line-width", "Maximal number of columns per line for REPL output.", 390)
val XreplDisableDisplay: Setting[Boolean] = BooleanSetting("-Xrepl-disable-display", "Do not display definitions in REPL.")
val XfatalWarnings: Setting[Boolean] = BooleanSetting("-Xfatal-warnings", "Fail the compilation if there are any warnings.")
val XverifySignatures: Setting[Boolean] = BooleanSetting("-Xverify-signatures", "Verify generic signatures in generated bytecode.")
val XignoreScala2Macros: Setting[Boolean] = BooleanSetting("-Xignore-scala2-macros", "Ignore errors when compiling code that calls Scala2 macros, these will fail at runtime.")
val XimportSuggestionTimeout: Setting[Int] = IntSetting("-Ximport-suggestion-timeout", "Timeout (in ms) for searching for import suggestions when errors are reported.", 8000)
val Xsemanticdb: Setting[Boolean] = BooleanSetting("-Xsemanticdb", "Store information in SemanticDB.").withAbbreviation("-Ysemanticdb")

val XmixinForceForwarders = ChoiceSetting(
name = "-Xmixin-force-forwarders",
Expand All @@ -138,7 +138,6 @@ class ScalaSettings extends Settings.SettingGroup with CommonScalaSettings {
}

/** -Y "Private" settings */
val YoverrideVars: Setting[Boolean] = BooleanSetting("-Yoverride-vars", "Allow vars to be overridden.")
val Yhelp: Setting[Boolean] = BooleanSetting("-Y", "Print a synopsis of private options.")
val Ycheck: Setting[List[String]] = PhasesSetting("-Ycheck", "Check the tree at the end of")
val YcheckMods: Setting[Boolean] = BooleanSetting("-Ycheck-mods", "Check that symbols and their defining trees have modifiers in sync.")
Expand All @@ -165,7 +164,6 @@ class ScalaSettings extends Settings.SettingGroup with CommonScalaSettings {
val Ydumpclasses: Setting[String] = StringSetting("-Ydump-classes", "dir", "Dump the generated bytecode to .class files (useful for reflective compilation that utilizes in-memory classloaders).", "")
val YstopAfter: Setting[List[String]] = PhasesSetting("-Ystop-after", "Stop after") withAbbreviation ("-stop") // backward compat
val YstopBefore: Setting[List[String]] = PhasesSetting("-Ystop-before", "Stop before") // stop before erasure as long as we have not debugged it fully
val YtraceContextCreation: Setting[Boolean] = BooleanSetting("-Ytrace-context-creation", "Store stack trace of context creations.")
val YshowSuppressedErrors: Setting[Boolean] = BooleanSetting("-Yshow-suppressed-errors", "Also show follow-on errors and warnings that are normally suppressed.")
val YdetailedStats: Setting[Boolean] = BooleanSetting("-Ydetailed-stats", "Show detailed internal compiler stats (needs Stats.enabled to be set to true).")
val YkindProjector: Setting[Boolean] = BooleanSetting("-Ykind-projector", "Allow `*` as wildcard to be compatible with kind projector.")
Expand All @@ -178,17 +176,14 @@ class ScalaSettings extends Settings.SettingGroup with CommonScalaSettings {
val YprintDebug: Setting[Boolean] = BooleanSetting("-Yprint-debug", "When printing trees, print some extra information useful for debugging.")
val YprintDebugOwners: Setting[Boolean] = BooleanSetting("-Yprint-debug-owners", "When printing trees, print owners of definitions.")
val YshowPrintErrors: Setting[Boolean] = BooleanSetting("-Yshow-print-errors", "Don't suppress exceptions thrown during tree printing.")
val YshowRawQuoteTrees: Setting[Boolean] = BooleanSetting("-Yshow-raw-tree", "Don't remove quote artifacts.")
val YtestPickler: Setting[Boolean] = BooleanSetting("-Ytest-pickler", "Self-test for pickling functionality; should be used with -Ystop-after:pickler.")
val YparallelPickler: Setting[Boolean] = BooleanSetting("-Yparallel-pickler", "Run part of the pickling phase in parallel, disable because it breaks some tests.")
val YcheckReentrant: Setting[Boolean] = BooleanSetting("-Ycheck-reentrant", "Check that compiled program does not contain vars that can be accessed from a global root.")
val YdropComments: Setting[Boolean] = BooleanSetting("-Ydrop-comments", "Drop comments when scanning source files.")
val YcookComments: Setting[Boolean] = BooleanSetting("-Ycook-comments", "Cook the comments (type check `@usecase`, etc.)")
val YforceSbtPhases: Setting[Boolean] = BooleanSetting("-Yforce-sbt-phases", "Run the phases used by sbt for incremental compilation (ExtractDependencies and ExtractAPI) even if the compiler is ran outside of sbt, for debugging.")
val YdumpSbtInc: Setting[Boolean] = BooleanSetting("-Ydump-sbt-inc", "For every compiled foo.scala, output the API representation and dependencies used for sbt incremental compilation in foo.inc, implies -Yforce-sbt-phases.")
val YcheckAllPatmat: Setting[Boolean] = BooleanSetting("-Ycheck-all-patmat", "Check exhaustivity and redundancy of all pattern matching (used for testing the algorithm).")
val YretainTrees: Setting[Boolean] = BooleanSetting("-Yretain-trees", "Retain trees for top-level classes, accessible from ClassSymbol#tree")
val Ysemanticdb: Setting[Boolean] = BooleanSetting("-Ysemanticdb", "Store information in SemanticDB.")
val YshowTreeIds: Setting[Boolean] = BooleanSetting("-Yshow-tree-ids", "Uniquely tag all tree nodes in debugging output.")
val YfromTastyIgnoreList: Setting[List[String]] = MultiStringSetting("-Yfrom-tasty-ignore-list", "file", "List of `tasty` files in jar files that will not be loaded when using -from-tasty")

Expand Down
3 changes: 1 addition & 2 deletions compiler/src/dotty/tools/dotc/core/Contexts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,7 @@ object Contexts {
private var creationTrace: Array[StackTraceElement] = _

private def setCreationTrace() =
if (this.settings.YtraceContextCreation.value)
creationTrace = (new Throwable).getStackTrace().take(20)
creationTrace = (new Throwable).getStackTrace().take(20)

/** Print all enclosing context's creation stacktraces */
def printCreationTraces() = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ExtractSemanticDB extends Phase:
override val phaseName: String = ExtractSemanticDB.name

override def isRunnable(using Context) =
super.isRunnable && ctx.settings.Ysemanticdb.value
super.isRunnable && ctx.settings.Xsemanticdb.value

// Check not needed since it does not transform trees
override def isCheckable: Boolean = false
Expand Down
8 changes: 2 additions & 6 deletions compiler/src/dotty/tools/dotc/typer/RefChecks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -413,12 +413,8 @@ object RefChecks {
else if (other.is(AbsOverride) && other.isIncompleteIn(clazz) && !member.is(AbsOverride))
overrideError("needs `abstract override` modifiers")
else if (member.is(Override) && other.is(Accessor) &&
other.accessedFieldOrGetter.is(Mutable, butNot = Lazy)) {
// !?! this is not covered by the spec. We need to resolve this either by changing the spec or removing the test here.
// !!! is there a !?! convention? I'm !!!ing this to make sure it turns up on my searches.
if (!ctx.settings.YoverrideVars.value)
overrideError("cannot override a mutable variable")
}
other.accessedFieldOrGetter.is(Mutable, butNot = Lazy))
overrideError("cannot override a mutable variable")
else if (member.isAnyOverride &&
!(member.owner.thisType.baseClasses exists (_ isSubClass other.owner)) &&
!member.is(Deferred) && !other.is(Deferred) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class BootstrappedOnlyCompilationTests extends ParallelTesting {
aggregateTests(
compileFilesInDir("tests/bench", defaultOptions),
compileFilesInDir("tests/pos-macros", defaultOptions),
compileFilesInDir("tests/pos-custom-args/semanticdb", defaultOptions.and("-Ysemanticdb")),
compileFilesInDir("tests/pos-custom-args/semanticdb", defaultOptions.and("-Xsemanticdb")),
).checkCompile()
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/test/dotty/tools/dotc/CompilationTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class CompilationTests {
Properties.compilerInterface, Properties.scalaLibrary, Properties.scalaAsm,
Properties.dottyInterfaces, Properties.jlineTerminal, Properties.jlineReader,
).mkString(File.pathSeparator),
Array("-Ycheck-reentrant", "-language:postfixOps", "-Ysemanticdb")
Array("-Ycheck-reentrant", "-language:postfixOps", "-Xsemanticdb")
)

val libraryDirs = List(Paths.get("library/src"), Paths.get("library/src-bootstrapped"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class SemanticdbTests:
val exitJava = javac.run(null, null, null, javaArgs:_*)
assert(exitJava == 0, "java compiler has errors")
val args = Array(
"-Ysemanticdb",
"-Xsemanticdb",
"-d", target.toString,
"-feature",
"-deprecation",
Expand Down
2 changes: 1 addition & 1 deletion compiler/test/dotty/tools/vulpix/TestConfiguration.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ object TestConfiguration {
"-Yno-deep-subtypes",
"-Yno-double-bindings",
"-Yforce-sbt-phases",
"-Ysemanticdb",
"-Xsemanticdb",
"-Xverify-signatures"
)

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/contributing/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ with `with-compiler` in their name.

### SemanticDB tests

The output of the `extractSemanticDB` phase, enabled with `-Ysemanticdb` is tested with the bootstrapped JUnit test
The output of the `extractSemanticDB` phase, enabled with `-Xsemanticdb` is tested with the bootstrapped JUnit test
`dotty.tools.dotc.semanticdb.SemanticdbTests`. It uses source files in `tests/semanticdb/expect` to generate
two kinds of output file that are compared with "expect files": placement of semanticdb symbol occurrences inline in
sourcecode (`*.expect.scala`), for human verification by inspection; and secondly metap formatted output which outputs
Expand Down
1 change: 0 additions & 1 deletion staging/src/scala/quoted/staging/QuoteDriver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ private class QuoteDriver(appClassloader: ClassLoader) extends Driver:
ictx

private def setToolboxSettings(ctx: FreshContext, settings: Toolbox.Settings): ctx.type =
ctx.setSetting(ctx.settings.YshowRawQuoteTrees, settings.showRawTree)
// An error in the generated code is a bug in the compiler
// Setting the throwing reporter however will report any exception
ctx.setReporter(new ThrowingReporter(ctx.reporter))
Expand Down
6 changes: 2 additions & 4 deletions staging/src/scala/quoted/staging/Toolbox.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,21 @@ object Toolbox:
end new

/** Setting of the Toolbox instance. */
case class Settings private (outDir: Option[String], showRawTree: Boolean, compilerArgs: List[String])
case class Settings private (outDir: Option[String], compilerArgs: List[String])

object Settings:

implicit def default: Settings = make()

/** Make toolbox settings
* @param outDir Output directory for the compiled quote. If set to None the output will be in memory
* @param showRawTree Do not remove quote tree artifacts
* @param compilerArgs Compiler arguments. Use only if you know what you are doing.
*/
def make( // TODO avoid using default parameters (for binary compat)
showRawTree: Boolean = false,
outDir: Option[String] = None,
compilerArgs: List[String] = Nil
): Settings =
new Settings(outDir, showRawTree, compilerArgs)
new Settings(outDir, compilerArgs)

end Settings

Expand Down