From abb392243783721e21bfb35187ce098e0a5fe898 Mon Sep 17 00:00:00 2001 From: rochala Date: Tue, 16 Apr 2024 13:06:36 +0200 Subject: [PATCH 01/19] Update scala settings --- Test.scala | 1 + .../tools/backend/jvm/BCodeHelpers.scala | 2 +- .../jvm/PostProcessorFrontendAccess.scala | 4 +- compiler/src/dotty/tools/dotc/Driver.scala | 2 +- .../tools/dotc/config/ScalaSettings.scala | 63 ++++++--- .../dotty/tools/dotc/config/Settings.scala | 133 ++++++++++-------- .../src/dotty/tools/dotc/core/Phases.scala | 6 +- .../dotty/tools/dotc/core/SymbolLoaders.scala | 6 +- .../dotty/tools/dotc/core/TypeErrors.scala | 4 +- .../tools/dotc/core/tasty/TreePickler.scala | 4 +- .../tools/dotc/core/tasty/TreeUnpickler.scala | 4 +- .../dotc/decompiler/IDEDecompilerDriver.scala | 2 +- .../tools/dotc/fromtasty/ReadTasty.scala | 8 +- .../dotc/interactive/InteractiveDriver.scala | 4 +- .../dotty/tools/dotc/parsing/Parsers.scala | 14 +- .../dotty/tools/dotc/parsing/Scanners.scala | 2 +- compiler/src/dotty/tools/dotc/report.scala | 4 +- .../src/dotty/tools/dotc/sbt/ExtractAPI.scala | 8 +- .../tools/dotc/sbt/ExtractDependencies.scala | 2 +- .../tools/dotc/transform/CookComments.scala | 2 +- .../dotc/transform/GenericSignatures.scala | 2 +- .../dotty/tools/dotc/transform/Pickler.scala | 10 +- .../dotty/tools/dotc/typer/TyperPhase.scala | 2 +- .../src/dotty/tools/repl/ReplDriver.scala | 4 +- .../quoted/runtime/impl/QuotesImpl.scala | 2 +- .../dotc/config/ScalaSettingsTests.scala | 53 +++++++ .../reference/changed-features/wildcards.md | 6 +- .../changed-features/wildcards.md | 6 +- .../a/src/main/scala/a/A.scala | 0 .../b/src/main/scala/b/B.scala | 0 .../build.sbt | 2 +- .../project/DottyInjectedPlugin.scala | 0 .../test | 0 .../a/src/main/scala/a/A.scala | 0 .../b-early-out/.keep | 0 .../b/src/main/scala/b/B.scala | 0 .../build.sbt | 4 +- .../c/src/main/scala/c/C.scala | 0 .../project/DottyInjectedPlugin.scala | 0 .../test | 0 .../a/src/main/scala/a/A.java | 0 .../a/src/main/scala/a/package.scala | 0 .../b-alt/.keep | 0 .../b/src/main/scala/b/B.scala | 0 .../build.sbt | 4 +- .../project/DottyInjectedPlugin.scala | 0 .../test | 0 .../a/src/main/scala/a/A.java | 0 .../a/src/main/scala/a/package.scala | 0 .../b-alt/.keep | 0 .../b/src/main/scala/b/B.scala | 0 .../build.sbt | 4 +- .../project/DottyInjectedPlugin.scala | 0 .../test | 0 .../a/src/main/scala/a/A.java | 0 .../a/src/main/scala/a/package.scala | 0 .../a_from_tasty/.keep | 0 .../b-alt/.keep | 0 .../b/src/main/scala/b/B.scala | 0 .../build.sbt | 12 +- .../project/DottyInjectedPlugin.scala | 0 .../test | 0 .../a-check/.keep | 0 .../a/src/main/scala/a/A.java | 0 .../a/src/main/scala/a/AImport.java | 0 .../a/src/main/scala/a/package.scala | 0 .../b-alt/.keep | 0 .../b/src/main/scala/b/B.scala | 0 .../b/src/main/scala/b/BImport.scala | 0 .../build.sbt | 8 +- .../c-alt/.keep | 0 .../c/src/main/scala/c/C.scala | 0 .../c/src/main/scala/c/CImport.scala | 0 .../project/DottyInjectedPlugin.scala | 0 .../test | 0 .../a/src/main/scala/a/A.java | 0 .../a/src/main/scala/a/package.scala | 0 .../b-alt/.keep | 0 .../b/src/main/scala/b/B.scala | 0 .../build.sbt | 4 +- .../project/DottyInjectedPlugin.scala | 0 .../test | 0 .../a/InnerClass.java | 0 .../a/InnerClassGen.java | 0 .../a/InnerClassSub.java | 0 .../a/RawTypes.java | 0 .../a/package.scala | 0 .../b/Test.scala | 0 .../build.sbt | 4 +- .../project/DottyInjectedPlugin.scala | 0 .../test | 0 .../a/src/main/scala/a/A.java | 0 .../a/src/main/scala/a/package.scala | 0 .../b-alt/.keep | 0 .../b/src/main/scala/b/B.scala | 0 .../build.sbt | 4 +- .../project/DottyInjectedPlugin.scala | 0 .../test | 0 sbt-test/pipelining/pipelining-test/test | 10 +- tests/neg/i2887b.check | 2 +- tests/neg/kind-projector-underscores.scala | 2 +- tests/neg/kind-projector.scala | 2 +- tests/pos/i16777.scala | 2 +- tests/pos/i19806/Module.scala | 2 +- tests/pos/kind-projector-underscores.scala | 2 +- tests/pos/kind-projector.scala | 2 +- tests/run-macros/i12351/Test_2.scala | 2 +- tests/run-macros/i12352/Main.scala | 2 +- tests/untried/neg/choices.check | 2 +- tests/untried/neg/choices.flags | 2 +- 110 files changed, 266 insertions(+), 172 deletions(-) create mode 100644 Test.scala rename sbt-test/pipelining/{Yearly-tasty-output-inline => Xearly-tasty-output-inline}/a/src/main/scala/a/A.scala (100%) rename sbt-test/pipelining/{Yearly-tasty-output-inline => Xearly-tasty-output-inline}/b/src/main/scala/b/B.scala (100%) rename sbt-test/pipelining/{Yearly-tasty-output-inline => Xearly-tasty-output-inline}/build.sbt (90%) rename sbt-test/pipelining/{Yearly-tasty-output-inline => Xearly-tasty-output-inline}/project/DottyInjectedPlugin.scala (100%) rename sbt-test/pipelining/{Yearly-tasty-output-inline => Xearly-tasty-output-inline}/test (100%) rename sbt-test/pipelining/{Yearly-tasty-output => Xearly-tasty-output}/a/src/main/scala/a/A.scala (100%) rename sbt-test/pipelining/{Yearly-tasty-output => Xearly-tasty-output}/b-early-out/.keep (100%) rename sbt-test/pipelining/{Yearly-tasty-output => Xearly-tasty-output}/b/src/main/scala/b/B.scala (100%) rename sbt-test/pipelining/{Yearly-tasty-output => Xearly-tasty-output}/build.sbt (87%) rename sbt-test/pipelining/{Yearly-tasty-output => Xearly-tasty-output}/c/src/main/scala/c/C.scala (100%) rename sbt-test/pipelining/{Yearly-tasty-output => Xearly-tasty-output}/project/DottyInjectedPlugin.scala (100%) rename sbt-test/pipelining/{Yearly-tasty-output => Xearly-tasty-output}/test (100%) rename sbt-test/pipelining/{Yjava-tasty-annotation => Xjava-tasty-annotation}/a/src/main/scala/a/A.java (100%) rename sbt-test/pipelining/{Yjava-tasty-annotation => Xjava-tasty-annotation}/a/src/main/scala/a/package.scala (100%) rename sbt-test/pipelining/{Yjava-tasty-annotation => Xjava-tasty-annotation}/b-alt/.keep (100%) rename sbt-test/pipelining/{Yjava-tasty-annotation => Xjava-tasty-annotation}/b/src/main/scala/b/B.scala (100%) rename sbt-test/pipelining/{Yjava-tasty-annotation => Xjava-tasty-annotation}/build.sbt (87%) rename sbt-test/pipelining/{Yjava-tasty-annotation => Xjava-tasty-annotation}/project/DottyInjectedPlugin.scala (100%) rename sbt-test/pipelining/{Yjava-tasty-annotation => Xjava-tasty-annotation}/test (100%) rename sbt-test/pipelining/{Yjava-tasty-enum => Xjava-tasty-enum}/a/src/main/scala/a/A.java (100%) rename sbt-test/pipelining/{Yjava-tasty-enum => Xjava-tasty-enum}/a/src/main/scala/a/package.scala (100%) rename sbt-test/pipelining/{Yjava-tasty-enum => Xjava-tasty-enum}/b-alt/.keep (100%) rename sbt-test/pipelining/{Yjava-tasty-enum => Xjava-tasty-enum}/b/src/main/scala/b/B.scala (100%) rename sbt-test/pipelining/{Yjava-tasty-enum => Xjava-tasty-enum}/build.sbt (92%) rename sbt-test/pipelining/{Yjava-tasty-enum => Xjava-tasty-enum}/project/DottyInjectedPlugin.scala (100%) rename sbt-test/pipelining/{Yjava-tasty-enum => Xjava-tasty-enum}/test (100%) rename sbt-test/pipelining/{Yjava-tasty-from-tasty => Xjava-tasty-from-tasty}/a/src/main/scala/a/A.java (100%) rename sbt-test/pipelining/{Yjava-tasty-from-tasty => Xjava-tasty-from-tasty}/a/src/main/scala/a/package.scala (100%) rename sbt-test/pipelining/{Yjava-tasty-from-tasty => Xjava-tasty-from-tasty}/a_from_tasty/.keep (100%) rename sbt-test/pipelining/{Yjava-tasty-from-tasty => Xjava-tasty-from-tasty}/b-alt/.keep (100%) rename sbt-test/pipelining/{Yjava-tasty-from-tasty => Xjava-tasty-from-tasty}/b/src/main/scala/b/B.scala (100%) rename sbt-test/pipelining/{Yjava-tasty-from-tasty => Xjava-tasty-from-tasty}/build.sbt (87%) rename sbt-test/pipelining/{Yjava-tasty-from-tasty => Xjava-tasty-from-tasty}/project/DottyInjectedPlugin.scala (100%) rename sbt-test/pipelining/{Yjava-tasty-from-tasty => Xjava-tasty-from-tasty}/test (100%) rename sbt-test/pipelining/{Yjava-tasty-fromjavaobject => Xjava-tasty-fromjavaobject}/a-check/.keep (100%) rename sbt-test/pipelining/{Yjava-tasty-fromjavaobject => Xjava-tasty-fromjavaobject}/a/src/main/scala/a/A.java (100%) rename sbt-test/pipelining/{Yjava-tasty-fromjavaobject => Xjava-tasty-fromjavaobject}/a/src/main/scala/a/AImport.java (100%) rename sbt-test/pipelining/{Yjava-tasty-fromjavaobject => Xjava-tasty-fromjavaobject}/a/src/main/scala/a/package.scala (100%) rename sbt-test/pipelining/{Yjava-tasty-fromjavaobject => Xjava-tasty-fromjavaobject}/b-alt/.keep (100%) rename sbt-test/pipelining/{Yjava-tasty-fromjavaobject => Xjava-tasty-fromjavaobject}/b/src/main/scala/b/B.scala (100%) rename sbt-test/pipelining/{Yjava-tasty-fromjavaobject => Xjava-tasty-fromjavaobject}/b/src/main/scala/b/BImport.scala (100%) rename sbt-test/pipelining/{Yjava-tasty-fromjavaobject => Xjava-tasty-fromjavaobject}/build.sbt (91%) rename sbt-test/pipelining/{Yjava-tasty-fromjavaobject => Xjava-tasty-fromjavaobject}/c-alt/.keep (100%) rename sbt-test/pipelining/{Yjava-tasty-fromjavaobject => Xjava-tasty-fromjavaobject}/c/src/main/scala/c/C.scala (100%) rename sbt-test/pipelining/{Yjava-tasty-fromjavaobject => Xjava-tasty-fromjavaobject}/c/src/main/scala/c/CImport.scala (100%) rename sbt-test/pipelining/{Yjava-tasty-fromjavaobject => Xjava-tasty-fromjavaobject}/project/DottyInjectedPlugin.scala (100%) rename sbt-test/pipelining/{Yjava-tasty-fromjavaobject => Xjava-tasty-fromjavaobject}/test (100%) rename sbt-test/pipelining/{Yjava-tasty-generic => Xjava-tasty-generic}/a/src/main/scala/a/A.java (100%) rename sbt-test/pipelining/{Yjava-tasty-generic => Xjava-tasty-generic}/a/src/main/scala/a/package.scala (100%) rename sbt-test/pipelining/{Yjava-tasty-generic => Xjava-tasty-generic}/b-alt/.keep (100%) rename sbt-test/pipelining/{Yjava-tasty-generic => Xjava-tasty-generic}/b/src/main/scala/b/B.scala (100%) rename sbt-test/pipelining/{Yjava-tasty-generic => Xjava-tasty-generic}/build.sbt (91%) rename sbt-test/pipelining/{Yjava-tasty-generic => Xjava-tasty-generic}/project/DottyInjectedPlugin.scala (100%) rename sbt-test/pipelining/{Yjava-tasty-generic => Xjava-tasty-generic}/test (100%) rename sbt-test/pipelining/{Yjava-tasty-paths => Xjava-tasty-paths}/a/InnerClass.java (100%) rename sbt-test/pipelining/{Yjava-tasty-paths => Xjava-tasty-paths}/a/InnerClassGen.java (100%) rename sbt-test/pipelining/{Yjava-tasty-paths => Xjava-tasty-paths}/a/InnerClassSub.java (100%) rename sbt-test/pipelining/{Yjava-tasty-paths => Xjava-tasty-paths}/a/RawTypes.java (100%) rename sbt-test/pipelining/{Yjava-tasty-paths => Xjava-tasty-paths}/a/package.scala (100%) rename sbt-test/pipelining/{Yjava-tasty-paths => Xjava-tasty-paths}/b/Test.scala (100%) rename sbt-test/pipelining/{Yjava-tasty-paths => Xjava-tasty-paths}/build.sbt (92%) rename sbt-test/pipelining/{Yjava-tasty-paths => Xjava-tasty-paths}/project/DottyInjectedPlugin.scala (100%) rename sbt-test/pipelining/{Yjava-tasty-paths => Xjava-tasty-paths}/test (100%) rename sbt-test/pipelining/{Yjava-tasty-result-types => Xjava-tasty-result-types}/a/src/main/scala/a/A.java (100%) rename sbt-test/pipelining/{Yjava-tasty-result-types => Xjava-tasty-result-types}/a/src/main/scala/a/package.scala (100%) rename sbt-test/pipelining/{Yjava-tasty-result-types => Xjava-tasty-result-types}/b-alt/.keep (100%) rename sbt-test/pipelining/{Yjava-tasty-result-types => Xjava-tasty-result-types}/b/src/main/scala/b/B.scala (100%) rename sbt-test/pipelining/{Yjava-tasty-result-types => Xjava-tasty-result-types}/build.sbt (92%) rename sbt-test/pipelining/{Yjava-tasty-result-types => Xjava-tasty-result-types}/project/DottyInjectedPlugin.scala (100%) rename sbt-test/pipelining/{Yjava-tasty-result-types => Xjava-tasty-result-types}/test (100%) diff --git a/Test.scala b/Test.scala new file mode 100644 index 000000000000..5486d1260b41 --- /dev/null +++ b/Test.scala @@ -0,0 +1 @@ +@main def hello = println("Hello, world!") diff --git a/compiler/src/dotty/tools/backend/jvm/BCodeHelpers.scala b/compiler/src/dotty/tools/backend/jvm/BCodeHelpers.scala index 385521e2785f..f8866f40d9d4 100644 --- a/compiler/src/dotty/tools/backend/jvm/BCodeHelpers.scala +++ b/compiler/src/dotty/tools/backend/jvm/BCodeHelpers.scala @@ -823,7 +823,7 @@ trait BCodeHelpers extends BCodeIdiomatic { // without it. This is particularly bad because the availability of // generic information could disappear as a consequence of a seemingly // unrelated change. - ctx.base.settings.YnoGenericSig.value + ctx.base.settings.XnoGenericSig.value || sym.is(Artifact) || sym.isAllOf(LiftedMethod) || sym.is(Bridge) diff --git a/compiler/src/dotty/tools/backend/jvm/PostProcessorFrontendAccess.scala b/compiler/src/dotty/tools/backend/jvm/PostProcessorFrontendAccess.scala index f7955cbb350c..41749967389e 100644 --- a/compiler/src/dotty/tools/backend/jvm/PostProcessorFrontendAccess.scala +++ b/compiler/src/dotty/tools/backend/jvm/PostProcessorFrontendAccess.scala @@ -121,10 +121,10 @@ object PostProcessorFrontendAccess { case (None, None) => "8" // least supported version by default override val debug: Boolean = ctx.debug - override val dumpClassesDirectory: Option[String] = s.Ydumpclasses.valueSetByUser + override val dumpClassesDirectory: Option[String] = s.Xdumpclasses.valueSetByUser override val outputDirectory: AbstractFile = s.outputDir.value override val mainClass: Option[String] = s.XmainClass.valueSetByUser - override val jarCompressionLevel: Int = s.YjarCompressionLevel.value + override val jarCompressionLevel: Int = s.XjarCompressionLevel.value override val backendParallelism: Int = s.YbackendParallelism.value override val backendMaxWorkerQueue: Option[Int] = s.YbackendWorkerQueue.valueSetByUser override val outputOnlyTasty: Boolean = s.YoutputOnlyTasty.value diff --git a/compiler/src/dotty/tools/dotc/Driver.scala b/compiler/src/dotty/tools/dotc/Driver.scala index 6625b5ca6ea2..98abe2ac6c38 100644 --- a/compiler/src/dotty/tools/dotc/Driver.scala +++ b/compiler/src/dotty/tools/dotc/Driver.scala @@ -84,7 +84,7 @@ class Driver { Positioned.init(using ictx) inContext(ictx) { - if !ctx.settings.YdropComments.value || ctx.settings.YreadComments.value then + if !ctx.settings.XdropComments.value || ctx.settings.XreadComments.value then ictx.setProperty(ContextDoc, new ContextDocstrings) val fileNamesOrNone = command.checkUsage(summary, sourcesRequired)(using ctx.settings)(using ctx.settingsState) fileNamesOrNone.map { fileNames => diff --git a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala index 94b6d8023c34..66be2b3c7317 100644 --- a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala +++ b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala @@ -3,7 +3,7 @@ package config import scala.language.unsafeNulls import dotty.tools.dotc.config.PathResolver.Defaults -import dotty.tools.dotc.config.Settings.{Setting, SettingGroup, SettingCategory} +import dotty.tools.dotc.config.Settings.{Setting, SettingGroup, SettingCategory, Deprecation} import dotty.tools.dotc.config.SourceVersion import dotty.tools.dotc.core.Contexts.* import dotty.tools.dotc.rewrites.Rewrites @@ -322,6 +322,21 @@ private sealed trait XSettings: val XmainClass: Setting[String] = StringSetting(AdvancedSetting, "Xmain-class", "path", "Class for manifest's Main-Class entry (only useful with -d )", "") val XimplicitSearchLimit: Setting[Int] = IntSetting(AdvancedSetting, "Ximplicit-search-limit", "Maximal number of expressions to be generated in an implicit search", 50000) + val XtermConflict: Setting[String] = ChoiceSetting(AdvancedSetting, "Xresolve-term-conflict", "strategy", "Resolve term conflicts", List("package", "object", "error"), "error") + val XnoGenericSig: Setting[Boolean] = BooleanSetting(AdvancedSetting, "Xno-generic-signatures", "Suppress generation of generic signatures for Java.") + val Xdumpclasses: Setting[String] = StringSetting(AdvancedSetting, "Xdump-classes", "dir", "Dump the generated bytecode to .class files (useful for reflective compilation that utilizes in-memory classloaders).", "") + val XjarCompressionLevel: Setting[Int] = IntChoiceSetting(AdvancedSetting, "Xjar-compression-level", "compression level to use when writing jar files", Deflater.DEFAULT_COMPRESSION to Deflater.BEST_COMPRESSION, Deflater.DEFAULT_COMPRESSION) + val XkindProjector: Setting[String] = ChoiceSetting(AdvancedSetting, "Xkind-projector", "[underscores, enable, disable]", "Allow `*` as type lambda placeholder to be compatible with kind projector. When invoked as -Xkind-projector:underscores will repurpose `_` to be a type parameter placeholder, this will disable usage of underscore as a wildcard.", List("disable", "", "underscores"), "disable", legacyArgs = true) + val XdropComments: Setting[Boolean] = BooleanSetting(AdvancedSetting, "Xdrop-docs", "Drop documentation when scanning source files.", aliases = List("-Xdrop-comments")) + val XcookComments: Setting[Boolean] = BooleanSetting(AdvancedSetting, "Xcook-docs", "Cook the documentation (type check `@usecase`, etc.)", aliases = List("-Xcook-comments")) + val XreadComments: Setting[Boolean] = BooleanSetting(AdvancedSetting, "Xread-docs", "Read documentation from tasty.") + val XnoDecodeStacktraces: Setting[Boolean] = BooleanSetting(AdvancedSetting, "Xno-decode-stacktraces", "Show raw StackOverflow stacktraces, instead of decoding them into triggering operations.") + val XnoEnrichErrorMessages: Setting[Boolean] = BooleanSetting(AdvancedSetting, "Xno-enrich-error-messages", "Show raw error messages, instead of enriching them with contextual information.") + val XdebugMacros: Setting[Boolean] = BooleanSetting(AdvancedSetting, "Xdebug-macros", "Show debug info when quote pattern match fails") + val XjavaTasty: Setting[Boolean] = BooleanSetting(AdvancedSetting, "Xjava-tasty", "Pickler phase should compute TASTy for .java defined symbols for use by build tools", aliases = List("-Xpickle-java"), preferPrevious = true) + val XearlyTastyOutput: Setting[AbstractFile] = OutputSetting(AdvancedSetting, "Xearly-tasty-output", "directory|jar", "Destination to write generated .tasty files to for use in pipelined compilation.", NoAbstractFile, aliases = List("-Xpickle-write"), preferPrevious = true) + val XallowOutlineFromTasty: Setting[Boolean] = BooleanSetting(AdvancedSetting, "Xallow-outline-from-tasty", "Allow outline TASTy to be loaded with the -from-tasty option.") + val XmixinForceForwarders = ChoiceSetting( AdvancedSetting, name = "Xmixin-force-forwarders", @@ -338,7 +353,19 @@ private sealed trait XSettings: val XmacroSettings: Setting[List[String]] = MultiStringSetting(AdvancedSetting, "Xmacro-settings", "setting1,setting2,..settingN", "List of settings which exposed to the macros") // Deprecated - val Xlint: Setting[_] = DeprecatedSetting(AdvancedSetting, "Xlint", "Enable or disable specific warnings", "Use -Wshadow to enable shadowing lints.") + val Xlint: Setting[List[ChoiceWithHelp[String]]] = MultiChoiceHelpSetting( + AdvancedSetting, + name = "Xlint", + helpArg = "advanced warning", + descr = "Enable or disable specific `lint` warnings", + choices = List( + ChoiceWithHelp("all", ""), + ChoiceWithHelp("private-shadow", "Warn if a private field or class parameter shadows a superclass field"), + ChoiceWithHelp("type-parameter-shadow", "Warn when a type parameter shadows a type already in the scope"), + ), + default = Nil, + deprecation = Some(Deprecation("Use -Wshadow to enable shadowing lints.", "-Wshadow")) + ) end XSettings @@ -360,7 +387,6 @@ private sealed trait YSettings: val YdebugError: Setting[Boolean] = BooleanSetting(ForkSetting, "Ydebug-error", "Print the stack trace when any error is caught.", false) val YdebugUnpickling: Setting[Boolean] = BooleanSetting(ForkSetting, "Ydebug-unpickling", "Print the stack trace when an error occurs when reading Tasty.", false) val YdebugCyclic: Setting[Boolean] = BooleanSetting(ForkSetting, "Ydebug-cyclic", "Print the stack trace when a cyclic reference error occurs.", false) - val YtermConflict: Setting[String] = ChoiceSetting(ForkSetting, "Yresolve-term-conflict", "strategy", "Resolve term conflicts", List("package", "object", "error"), "error") val Ylog: Setting[List[String]] = PhasesSetting(ForkSetting, "Ylog", "Log operations during") val YlogClasspath: Setting[Boolean] = BooleanSetting(ForkSetting, "Ylog-classpath", "Output information about what classpath is being applied.") val YdisableFlatCpCaching: Setting[Boolean] = BooleanSetting(ForkSetting, "YdisableFlatCpCaching", "Do not cache flat classpath representation of classpath elements from jars across compiler instances.") @@ -369,18 +395,14 @@ private sealed trait YSettings: val YnoImports: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-imports", "Compile without importing scala.*, java.lang.*, or Predef.") val Yimports: Setting[List[String]] = MultiStringSetting(ForkSetting, "Yimports", helpArg="", "Custom root imports. If set, none of scala.*, java.lang.*, or Predef.* will be imported unless explicitly included.") - val YnoGenericSig: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-generic-signatures", "Suppress generation of generic signatures for Java.") val YnoPredef: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-predef", "Compile without importing Predef.") val Yskip: Setting[List[String]] = PhasesSetting(ForkSetting, "Yskip", "Skip") - val Ydumpclasses: Setting[String] = StringSetting(ForkSetting, "Ydump-classes", "dir", "Dump the generated bytecode to .class files (useful for reflective compilation that utilizes in-memory classloaders).", "") - val YjarCompressionLevel: Setting[Int] = IntChoiceSetting(ForkSetting, "Yjar-compression-level", "compression level to use when writing jar files", Deflater.DEFAULT_COMPRESSION to Deflater.BEST_COMPRESSION, Deflater.DEFAULT_COMPRESSION) val YbackendParallelism: Setting[Int] = IntChoiceSetting(ForkSetting, "Ybackend-parallelism", "maximum worker threads for backend", 1 to 16, 1) val YbackendWorkerQueue: Setting[Int] = IntChoiceSetting(ForkSetting, "Ybackend-worker-queue", "backend threads worker queue size", 0 to 1000, 0) val YstopAfter: Setting[List[String]] = PhasesSetting(ForkSetting, "Ystop-after", "Stop after", aliases = List("-stop")) // backward compat val YstopBefore: Setting[List[String]] = PhasesSetting(ForkSetting, "Ystop-before", "Stop before") // stop before erasure as long as we have not debugged it fully val YshowSuppressedErrors: Setting[Boolean] = BooleanSetting(ForkSetting, "Yshow-suppressed-errors", "Also show follow-on errors and warnings that are normally suppressed.") val YdetailedStats: Setting[Boolean] = BooleanSetting(ForkSetting, "Ydetailed-stats", "Show detailed internal compiler stats (needs Stats.enabled to be set to true).") - val YkindProjector: Setting[String] = ChoiceSetting(ForkSetting, "Ykind-projector", "[underscores, enable, disable]", "Allow `*` as type lambda placeholder to be compatible with kind projector. When invoked as -Ykind-projector:underscores will repurpose `_` to be a type parameter placeholder, this will disable usage of underscore as a wildcard.", List("disable", "", "underscores"), "disable", legacyArgs = true) val YprintPos: Setting[Boolean] = BooleanSetting(ForkSetting, "Yprint-pos", "Show tree positions.") val YprintPosSyms: Setting[Boolean] = BooleanSetting(ForkSetting, "Yprint-pos-syms", "Show symbol definitions positions.") val YnoDeepSubtypes: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-deep-subtypes", "Throw an exception on deep subtyping call stacks.") @@ -396,9 +418,6 @@ private sealed trait YSettings: val YtestPickler: Setting[Boolean] = BooleanSetting(ForkSetting, "Ytest-pickler", "Self-test for pickling functionality; should be used with -Ystop-after:pickler.") val YtestPicklerCheck: Setting[Boolean] = BooleanSetting(ForkSetting, "Ytest-pickler-check", "Self-test for pickling -print-tasty output; should be used with -Ytest-pickler.") val YcheckReentrant: Setting[Boolean] = BooleanSetting(ForkSetting, "Ycheck-reentrant", "Check that compiled program does not contain vars that can be accessed from a global root.") - val YdropComments: Setting[Boolean] = BooleanSetting(ForkSetting, "Ydrop-docs", "Drop documentation when scanning source files.", aliases = List("-Ydrop-comments")) - val YcookComments: Setting[Boolean] = BooleanSetting(ForkSetting, "Ycook-docs", "Cook the documentation (type check `@usecase`, etc.)", aliases = List("-Ycook-comments")) - val YreadComments: Setting[Boolean] = BooleanSetting(ForkSetting, "Yread-docs", "Read documentation from tasty.") val YforceSbtPhases: Setting[Boolean] = BooleanSetting(ForkSetting, "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(ForkSetting, "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(ForkSetting, "Ycheck-all-patmat", "Check exhaustivity and redundancy of all pattern matching (used for testing the algorithm).") @@ -438,16 +457,22 @@ private sealed trait YSettings: val YnoDoubleBindings: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-double-bindings", "Assert no namedtype is bound twice (should be enabled only if program is error-free).") val YshowVarBounds: Setting[Boolean] = BooleanSetting(ForkSetting, "Yshow-var-bounds", "Print type variables with their bounds.") - val YnoDecodeStacktraces: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-decode-stacktraces", "Show raw StackOverflow stacktraces, instead of decoding them into triggering operations.") - val YnoEnrichErrorMessages: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-enrich-error-messages", "Show raw error messages, instead of enriching them with contextual information.") - val Yinstrument: Setting[Boolean] = BooleanSetting(ForkSetting, "Yinstrument", "Add instrumentation code that counts allocations and closure creations.") val YinstrumentDefs: Setting[Boolean] = BooleanSetting(ForkSetting, "Yinstrument-defs", "Add instrumentation code that counts method calls; needs -Yinstrument to be set, too.") - val YdebugMacros: Setting[Boolean] = BooleanSetting(ForkSetting, "Ydebug-macros", "Show debug info when quote pattern match fails") - - // Pipeline compilation options - val YjavaTasty: Setting[Boolean] = BooleanSetting(ForkSetting, "Yjava-tasty", "Pickler phase should compute TASTy for .java defined symbols for use by build tools", aliases = List("-Ypickle-java"), preferPrevious = true) - val YearlyTastyOutput: Setting[AbstractFile] = OutputSetting(ForkSetting, "Yearly-tasty-output", "directory|jar", "Destination to write generated .tasty files to for use in pipelined compilation.", NoAbstractFile, aliases = List("-Ypickle-write"), preferPrevious = true) - val YallowOutlineFromTasty: Setting[Boolean] = BooleanSetting(ForkSetting, "Yallow-outline-from-tasty", "Allow outline TASTy to be loaded with the -from-tasty option.") + // Deprecated: lifted from -Y to -X + val YtermConflict: Setting[String] = ChoiceSetting(ForkSetting, "Yresolve-term-conflict", "strategy", "Resolve term conflicts", List("package", "object", "error"), "error", deprecation = Some(Deprecation("Use -Xresolve-term-conflict instead.", "-Xresolve-term-conflict"))) + val YnoGenericSig: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-generic-signatures", "Suppress generation of generic signatures for Java.", deprecation = Some(Deprecation("Use -Xno-generic-signatures instead.", "-Xno-generic-signatures"))) + val Ydumpclasses: Setting[String] = StringSetting(ForkSetting, "Ydump-classes", "dir", "Dump the generated bytecode to .class files (useful for reflective compilation that utilizes in-memory classloaders).", default = "", deprecation = Some(Deprecation("Use -Xdump-classes instead.", "-Xdump-classes"))) + val YjarCompressionLevel: Setting[Int] = IntChoiceSetting(ForkSetting, "Yjar-compression-level", "compression level to use when writing jar files", Deflater.DEFAULT_COMPRESSION to Deflater.BEST_COMPRESSION, Deflater.DEFAULT_COMPRESSION, deprecation = Some(Deprecation("Use -Xjar-compression-level instead.", "-Xjar-compression-level"))) + val YkindProjector: Setting[String] = ChoiceSetting(ForkSetting, "Ykind-projector", "[underscores, enable, disable]", "Allow `*` as type lambda placeholder to be compatible with kind projector. When invoked as -Ykind-projector:underscores will repurpose `_` to be a type parameter placeholder, this will disable usage of underscore as a wildcard.", List("disable", "", "underscores"), "disable", legacyArgs = true, deprecation = Some(Deprecation("Use -Xkind-projector instead.", "-Xkind-projector"))) + val YdropComments: Setting[Boolean] = BooleanSetting(ForkSetting, "Ydrop-docs", "Drop documentation when scanning source files.", aliases = List("-Ydrop-comments"), deprecation = Some(Deprecation("Use -Xdrop-docs instead.", "-Xdrop-docs"))) + val YcookComments: Setting[Boolean] = BooleanSetting(ForkSetting, "Ycook-docs", "Cook the documentation (type check `@usecase`, etc.)", aliases = List("-Ycook-comments"), deprecation = Some(Deprecation("Use -Xcook-docs instead.", "-Xcook-docs"))) + val YreadComments: Setting[Boolean] = BooleanSetting(ForkSetting, "Yread-docs", "Read documentation from tasty.", deprecation = Some(Deprecation("Use -Xread-docs instead.", "-Xread-docs"))) + val YnoDecodeStacktraces: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-decode-stacktraces", "Show raw StackOverflow stacktraces, instead of decoding them into triggering operations.", deprecation = Some(Deprecation("Use -Xno-decode-stacktraces instead.", "-Xno-decode-stacktraces"))) + val YnoEnrichErrorMessages: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-enrich-error-messages", "Show raw error messages, instead of enriching them with contextual information.", deprecation = Some(Deprecation("Use -Xno-enrich-error-messages instead.", "-Xno-enrich-error-messages"))) + val YdebugMacros: Setting[Boolean] = BooleanSetting(ForkSetting, "Ydebug-macros", "Show debug info when quote pattern match fails", deprecation = Some(Deprecation("Use -Xdebug-macros instead.", "-Xdebug-macros"))) + val YjavaTasty: Setting[Boolean] = BooleanSetting(ForkSetting, "Yjava-tasty", "Pickler phase should compute TASTy for .java defined symbols for use by build tools", aliases = List("-Ypickle-java"), preferPrevious = true, deprecation = Some(Deprecation("Use -Xjava-tasty instead.", "-Xjava-tasty"))) + val YearlyTastyOutput: Setting[AbstractFile] = OutputSetting(ForkSetting, "Yearly-tasty-output", "directory|jar", "Destination to write generated .tasty files to for use in pipelined compilation.", NoAbstractFile, aliases = List("-Ypickle-write"), preferPrevious = true, deprecation = Some(Deprecation("Use -Xearly-tasty-output instead.", "-Xearly-tasty-output"))) + val YallowOutlineFromTasty: Setting[Boolean] = BooleanSetting(ForkSetting, "Yallow-outline-from-tasty", "Allow outline TASTy to be loaded with the -from-tasty option.", deprecation = Some(Deprecation("Use -Xallow-outline-from-tasty instead.", "-Xallow-outline-from-tasty"))) end YSettings diff --git a/compiler/src/dotty/tools/dotc/config/Settings.scala b/compiler/src/dotty/tools/dotc/config/Settings.scala index 241ab34052a1..80e8c839cef1 100644 --- a/compiler/src/dotty/tools/dotc/config/Settings.scala +++ b/compiler/src/dotty/tools/dotc/config/Settings.scala @@ -60,6 +60,9 @@ object Settings: def warn(msg: String): Settings.ArgsSummary = ArgsSummary(sstate, arguments.tail, errors, warnings :+ msg) + + def deprecated(msg: String, extraArgs: List[String]): Settings.ArgsSummary = + ArgsSummary(sstate, extraArgs ++ arguments.tail, errors, warnings :+ msg) } @unshared @@ -81,9 +84,10 @@ object Settings: ignoreInvalidArgs: Boolean = false, preferPrevious: Boolean = false, propertyClass: Option[Class[?]] = None, - deprecationMsg: Option[String] = None, - // kept only for -Ykind-projector option compatibility - legacyArgs: Boolean = false)(private[Settings] val idx: Int) { + deprecation: Option[Deprecation] = None, + // kept only for -Xkind-projector option compatibility + legacyArgs: Boolean = false)(private[Settings] val idx: Int + ): validateSettingString(prefix.getOrElse(name)) aliases.foreach(validateSettingString) @@ -108,14 +112,13 @@ object Settings: def acceptsNoArg: Boolean = summon[ClassTag[T]] == BooleanTag || summon[ClassTag[T]] == OptionTag || choices.exists(_.contains("")) def legalChoices: String = - choices match { + choices match case Some(xs) if xs.isEmpty => "" case Some(r: Range) => s"${r.head}..${r.last}" case Some(xs) => xs.mkString(", ") case None => "" - } - def tryToSet(state: ArgsSummary): ArgsSummary = { + def tryToSet(state: ArgsSummary): ArgsSummary = val ArgsSummary(sstate, arg :: args, errors, warnings) = state: @unchecked def update(value: Any, args: List[String]): ArgsSummary = var dangers = warnings @@ -136,29 +139,23 @@ object Settings: def ignoreValue(args: List[String]): ArgsSummary = ArgsSummary(sstate, args, errors, warnings) - def fail(msg: String, args: List[String]) = - ArgsSummary(sstate, args, errors :+ msg, warnings) - - def warn(msg: String, args: List[String]) = - ArgsSummary(sstate, args, errors, warnings :+ msg) - def missingArg = val msg = s"missing argument for option $name" - if ignoreInvalidArgs then warn(msg + ", the tag was ignored", args) else fail(msg, args) + if ignoreInvalidArgs then state.warn(msg + ", the tag was ignored") else state.fail(msg) def invalidChoices(invalid: List[String]) = val msg = s"invalid choice(s) for $name: ${invalid.mkString(",")}" - if ignoreInvalidArgs then warn(msg + ", the tag was ignored", args) else fail(msg, args) + if ignoreInvalidArgs then state.warn(msg + ", the tag was ignored") else state.fail(msg) def setBoolean(argValue: String, args: List[String]) = if argValue.equalsIgnoreCase("true") || argValue.isEmpty then update(true, args) else if argValue.equalsIgnoreCase("false") then update(false, args) - else fail(s"$argValue is not a valid choice for boolean setting $name", args) + else state.fail(s"$argValue is not a valid choice for boolean setting $name") def setString(argValue: String, args: List[String]) = choices match case Some(xs) if !xs.contains(argValue) => - fail(s"$argValue is not a valid choice for $name", args) + state.fail(s"$argValue is not a valid choice for $name") case _ => update(argValue, args) @@ -167,19 +164,19 @@ object Settings: val x = argValue.toInt choices match case Some(r: Range) if x < r.head || r.last < x => - fail(s"$argValue is out of legal range ${r.head}..${r.last} for $name", args) + state.fail(s"$argValue is out of legal range ${r.head}..${r.last} for $name") case Some(xs) if !xs.contains(x) => - fail(s"$argValue is not a valid choice for $name", args) + state.fail(s"$argValue is not a valid choice for $name") case _ => update(x, args) catch case _: NumberFormatException => - fail(s"$argValue is not an integer argument for $name", args) + state.fail(s"$argValue is not an integer argument for $name") def setOutput(argValue: String, args: List[String]) = val path = Directory(argValue) val isJar = path.ext.isJar if (!isJar && !path.isDirectory) - fail(s"'$argValue' does not exist or is not a directory or .jar file", args) + state.fail(s"'$argValue' does not exist or is not a directory or .jar file") else { val output = if (isJar) JarArchive.create(path) else new PlainDirectory(path) update(output, args) @@ -188,7 +185,7 @@ object Settings: def setVersion(argValue: String, args: List[String]) = ScalaVersion.parse(argValue) match { case Success(v) => update(v, args) - case Failure(ex) => fail(ex.getMessage, args) + case Failure(ex) => state.fail(ex.getMessage) } def appendList(strings: List[String], args: List[String]) = @@ -241,14 +238,35 @@ object Settings: if(prefix.isEmpty) arg.dropWhile(_ != ':').drop(1) else arg.drop(prefix.get.length) if matches(arg) then - if deprecationMsg.isDefined then - warn(s"Option $name is deprecated: ${deprecationMsg.get}", args) - else - doSet(argValRest) + deprecation match + case Some(Deprecation(msg, replacedBy, mapArguments)) => + val (adjustedOption, state1) = mapArguments(argValRest, state) + val substitutedArg = if adjustedOption.nonEmpty then + s"$replacedBy:$adjustedOption" + else replacedBy + state1.deprecated(s"Option $name is deprecated: $msg", List(substitutedArg)) + case None => doSet(argValRest) else state - } - } + end tryToSet + end Setting + + /** + * Class used for deprecating purposes. + * It contains all necessary information to deprecate given option. + * Scala Settings are considered deprecated when this object is present at their creation site. + * + * @param msg deprecation message that will be displayed in following format: s"Option $name is deprecated: $msg" + * @param replacedBy option that is substituting current option + * @param updateChoices a function used to map available options to different ones with access to the state. + * It allows to append additional warnings or failing the compilation depending on the case e.g. + * when there is no option that can be replace deprecated one. + */ + case class Deprecation( + msg: String, + replacedBy: String, + updateChoices: (String, ArgsSummary) => (String, ArgsSummary) = (option, state) => (option, state) + ) object Setting: extension [T](setting: Setting[T]) @@ -333,60 +351,57 @@ object Settings: def processArguments(arguments: List[String], processAll: Boolean, settingsState: SettingsState = defaultState): ArgsSummary = processArguments(ArgsSummary(settingsState, arguments, Nil, Nil), processAll, Nil) - def publish[T](settingf: Int => Setting[T]): Setting[T] = { + def publish[T](settingf: Int => Setting[T]): Setting[T] = val setting = settingf(_allSettings.length) _allSettings += setting setting - } def prependName(name: String): String = assert(!name.startsWith("-"), s"Setting $name cannot start with -") "-" + name - def BooleanSetting(category: SettingCategory, name: String, descr: String, initialValue: Boolean = false, aliases: List[String] = Nil, preferPrevious: Boolean = false): Setting[Boolean] = - publish(Setting(category, prependName(name), descr, initialValue, aliases = aliases, preferPrevious = preferPrevious)) + def BooleanSetting(category: SettingCategory, name: String, descr: String, initialValue: Boolean = false, aliases: List[String] = Nil, preferPrevious: Boolean = false, deprecation: Option[Deprecation] = None): Setting[Boolean] = + publish(Setting(category, prependName(name), descr, initialValue, aliases = aliases, preferPrevious = preferPrevious, deprecation = deprecation)) - def StringSetting(category: SettingCategory, name: String, helpArg: String, descr: String, default: String, aliases: List[String] = Nil): Setting[String] = - publish(Setting(category, prependName(name), descr, default, helpArg, aliases = aliases)) + def StringSetting(category: SettingCategory, name: String, helpArg: String, descr: String, default: String, aliases: List[String] = Nil, deprecation: Option[Deprecation] = None): Setting[String] = + publish(Setting(category, prependName(name), descr, default, helpArg, aliases = aliases, deprecation = deprecation)) - def ChoiceSetting(category: SettingCategory, name: String, helpArg: String, descr: String, choices: List[String], default: String, aliases: List[String] = Nil, legacyArgs: Boolean = false): Setting[String] = - publish(Setting(category, prependName(name), descr, default, helpArg, Some(choices), aliases = aliases, legacyArgs = legacyArgs)) + def ChoiceSetting(category: SettingCategory, name: String, helpArg: String, descr: String, choices: List[String], default: String, aliases: List[String] = Nil, legacyArgs: Boolean = false, deprecation: Option[Deprecation] = None): Setting[String] = + publish(Setting(category, prependName(name), descr, default, helpArg, Some(choices), aliases = aliases, legacyArgs = legacyArgs, deprecation = deprecation)) - def MultiChoiceSetting(category: SettingCategory, name: String, helpArg: String, descr: String, choices: List[String], default: List[String], aliases: List[String] = Nil): Setting[List[String]] = - publish(Setting(category, prependName(name), descr, default, helpArg, Some(choices), aliases = aliases)) + def MultiChoiceSetting(category: SettingCategory, name: String, helpArg: String, descr: String, choices: List[String], default: List[String], aliases: List[String] = Nil, deprecation: Option[Deprecation] = None): Setting[List[String]] = + publish(Setting(category, prependName(name), descr, default, helpArg, Some(choices), aliases = aliases, deprecation = deprecation)) - def MultiChoiceHelpSetting(category: SettingCategory, name: String, helpArg: String, descr: String, choices: List[ChoiceWithHelp[String]], default: List[ChoiceWithHelp[String]], aliases: List[String] = Nil): Setting[List[ChoiceWithHelp[String]]] = - publish(Setting(category, prependName(name), descr, default, helpArg, Some(choices), aliases = aliases)) + def MultiChoiceHelpSetting(category: SettingCategory, name: String, helpArg: String, descr: String, choices: List[ChoiceWithHelp[String]], default: List[ChoiceWithHelp[String]], aliases: List[String] = Nil, deprecation: Option[Deprecation] = None): Setting[List[ChoiceWithHelp[String]]] = + publish(Setting(category, prependName(name), descr, default, helpArg, Some(choices), aliases = aliases, deprecation = deprecation)) - def IntSetting(category: SettingCategory, name: String, descr: String, default: Int, aliases: List[String] = Nil): Setting[Int] = - publish(Setting(category, prependName(name), descr, default, aliases = aliases)) + def IntSetting(category: SettingCategory, name: String, descr: String, default: Int, aliases: List[String] = Nil, deprecation: Option[Deprecation] = None): Setting[Int] = + publish(Setting(category, prependName(name), descr, default, aliases = aliases, deprecation = deprecation)) - def IntChoiceSetting(category: SettingCategory, name: String, descr: String, choices: Seq[Int], default: Int): Setting[Int] = - publish(Setting(category, prependName(name), descr, default, choices = Some(choices))) + def IntChoiceSetting(category: SettingCategory, name: String, descr: String, choices: Seq[Int], default: Int, deprecation: Option[Deprecation] = None): Setting[Int] = + publish(Setting(category, prependName(name), descr, default, choices = Some(choices), deprecation = deprecation)) - def MultiStringSetting(category: SettingCategory, name: String, helpArg: String, descr: String, default: List[String] = Nil, aliases: List[String] = Nil): Setting[List[String]] = - publish(Setting(category, prependName(name), descr, default, helpArg, aliases = aliases)) + def MultiStringSetting(category: SettingCategory, name: String, helpArg: String, descr: String, default: List[String] = Nil, aliases: List[String] = Nil, deprecation: Option[Deprecation] = None): Setting[List[String]] = + publish(Setting(category, prependName(name), descr, default, helpArg, aliases = aliases, deprecation = deprecation)) - def OutputSetting(category: SettingCategory, name: String, helpArg: String, descr: String, default: AbstractFile, aliases: List[String] = Nil, preferPrevious: Boolean = false): Setting[AbstractFile] = - publish(Setting(category, prependName(name), descr, default, helpArg, aliases = aliases, preferPrevious = preferPrevious)) + def OutputSetting(category: SettingCategory, name: String, helpArg: String, descr: String, default: AbstractFile, aliases: List[String] = Nil, preferPrevious: Boolean = false, deprecation: Option[Deprecation] = None): Setting[AbstractFile] = + publish(Setting(category, prependName(name), descr, default, helpArg, aliases = aliases, preferPrevious = preferPrevious, deprecation = deprecation)) - def PathSetting(category: SettingCategory, name: String, descr: String, default: String, aliases: List[String] = Nil): Setting[String] = - publish(Setting(category, prependName(name), descr, default, aliases = aliases)) + def PathSetting(category: SettingCategory, name: String, descr: String, default: String, aliases: List[String] = Nil, deprecation: Option[Deprecation] = None): Setting[String] = + publish(Setting(category, prependName(name), descr, default, aliases = aliases, deprecation = deprecation)) - def PhasesSetting(category: SettingCategory, name: String, descr: String, default: String = "", aliases: List[String] = Nil): Setting[List[String]] = - publish(Setting(category, prependName(name), descr, if (default.isEmpty) Nil else List(default), aliases = aliases)) + def PhasesSetting(category: SettingCategory, name: String, descr: String, default: String = "", aliases: List[String] = Nil, deprecation: Option[Deprecation] = None): Setting[List[String]] = + publish(Setting(category, prependName(name), descr, if (default.isEmpty) Nil else List(default), aliases = aliases, deprecation = deprecation)) - def PrefixSetting(category: SettingCategory, name: String, descr: String): Setting[List[String]] = + def PrefixSetting(category: SettingCategory, name: String, descr: String, deprecation: Option[Deprecation] = None): Setting[List[String]] = val prefix = name.takeWhile(_ != '<') - publish(Setting(category, "-" + name, descr, Nil, prefix = Some(prefix))) + publish(Setting(category, "-" + name, descr, Nil, prefix = Some(prefix), deprecation = deprecation)) - def VersionSetting(category: SettingCategory, name: String, descr: String, default: ScalaVersion = NoScalaVersion, legacyArgs: Boolean = false): Setting[ScalaVersion] = - publish(Setting(category, prependName(name), descr, default, legacyArgs = legacyArgs)) + def VersionSetting(category: SettingCategory, name: String, descr: String, default: ScalaVersion = NoScalaVersion, legacyArgs: Boolean = false, deprecation: Option[Deprecation] = None): Setting[ScalaVersion] = + publish(Setting(category, prependName(name), descr, default, legacyArgs = legacyArgs, deprecation = deprecation)) - def OptionSetting[T: ClassTag](category: SettingCategory, name: String, descr: String, aliases: List[String] = Nil): Setting[Option[T]] = - publish(Setting(category, prependName(name), descr, None, propertyClass = Some(summon[ClassTag[T]].runtimeClass), aliases = aliases)) + def OptionSetting[T: ClassTag](category: SettingCategory, name: String, descr: String, aliases: List[String] = Nil, deprecation: Option[Deprecation] = None): Setting[Option[T]] = + publish(Setting(category, prependName(name), descr, None, propertyClass = Some(summon[ClassTag[T]].runtimeClass), aliases = aliases, deprecation = deprecation)) - def DeprecatedSetting(category: SettingCategory, name: String, descr: String, deprecationMsg: String): Setting[Boolean] = - publish(Setting(category, prependName(name), descr, false, deprecationMsg = Some(deprecationMsg))) } end Settings diff --git a/compiler/src/dotty/tools/dotc/core/Phases.scala b/compiler/src/dotty/tools/dotc/core/Phases.scala index 89ea4dd6aa50..7f925b0fc322 100644 --- a/compiler/src/dotty/tools/dotc/core/Phases.scala +++ b/compiler/src/dotty/tools/dotc/core/Phases.scala @@ -349,15 +349,15 @@ object Phases { def subPhases: List[Run.SubPhase] = Nil final def traversals: Int = if subPhases.isEmpty then 1 else subPhases.length - /** skip the phase for a Java compilation unit, may depend on -Yjava-tasty */ + /** skip the phase for a Java compilation unit, may depend on -Xjava-tasty */ def skipIfJava(using Context): Boolean = true final def isAfterLastJavaPhase(using Context): Boolean = - // With `-Yjava-tasty` nominally the final phase is expected be ExtractAPI, + // With `-Xjava-tasty` nominally the final phase is expected be ExtractAPI, // otherwise drop Java sources at the end of TyperPhase. // Checks if the last Java phase is before this phase, // which always fails if the terminal phase is before lastJavaPhase. - val lastJavaPhase = if ctx.settings.YjavaTasty.value then sbtExtractAPIPhase else typerPhase + val lastJavaPhase = if ctx.settings.XjavaTasty.value then sbtExtractAPIPhase else typerPhase lastJavaPhase <= this /** @pre `isRunnable` returns true */ diff --git a/compiler/src/dotty/tools/dotc/core/SymbolLoaders.scala b/compiler/src/dotty/tools/dotc/core/SymbolLoaders.scala index fdc1ba9697d0..51e6a5e6138a 100644 --- a/compiler/src/dotty/tools/dotc/core/SymbolLoaders.scala +++ b/compiler/src/dotty/tools/dotc/core/SymbolLoaders.scala @@ -80,12 +80,12 @@ object SymbolLoaders { // offer a setting to resolve the conflict one way or the other. // This was motivated by the desire to use YourKit probes, which // require yjp.jar at runtime. See SI-2089. - if (ctx.settings.YtermConflict.value == "package" || ctx.mode.is(Mode.Interactive)) { + if (ctx.settings.XtermConflict.value == "package" || ctx.mode.is(Mode.Interactive)) { report.warning( s"Resolving package/object name conflict in favor of package ${preExisting.fullName}. The object will be inaccessible.") owner.asClass.delete(preExisting) } - else if (ctx.settings.YtermConflict.value == "object") { + else if (ctx.settings.XtermConflict.value == "object") { report.warning( s"Resolving package/object name conflict in favor of object ${preExisting.fullName}. The package will be inaccessible.") return NoSymbol @@ -470,7 +470,7 @@ class TastyLoader(val tastyFile: AbstractFile) extends SymbolLoader { new ClassfileTastyUUIDParser(classfile)(ctx).checkTastyUUID(tastyUUID) else // This will be the case in any of our tests that compile with `-Youtput-only-tasty`, or when - // tasty file compiled by `-Yearly-tasty-output-write` comes from an early output jar. + // tasty file compiled by `-Xearly-tasty-output-write` comes from an early output jar. report.inform(s"No classfiles found for $tastyFile when checking TASTy UUID") private def checkBeTastyUUID(tastyFile: AbstractFile, tastyBytes: Array[Byte])(using Context): Unit = diff --git a/compiler/src/dotty/tools/dotc/core/TypeErrors.scala b/compiler/src/dotty/tools/dotc/core/TypeErrors.scala index c71c20a38eb9..5b19fe0e7bdd 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeErrors.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeErrors.scala @@ -102,7 +102,7 @@ extends TypeError: em"""Recursion limit exceeded. |Maybe there is an illegal cyclic reference? |If that's not the case, you could also try to increase the stacksize using the -Xss JVM option. - |For the unprocessed stack trace, compile with -Yno-decode-stacktraces. + |For the unprocessed stack trace, compile with -Xno-decode-stacktraces. |A recurring operation is (inner to outer): |${opsString(mostCommon).stripMargin}""" @@ -122,7 +122,7 @@ object handleRecursive: e def apply(op: String, details: => String, exc: Throwable, weight: Int = 1)(using Context): Nothing = - if ctx.settings.YnoDecodeStacktraces.value then + if ctx.settings.XnoDecodeStacktraces.value then throw exc else exc match case _: RecursionOverflow => diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala index 4b2b218edb58..186e039c4d74 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala @@ -385,7 +385,7 @@ class TreePickler(pickler: TastyPickler, attributes: Attributes) { } catch case ex: Throwable => - if !ctx.settings.YnoDecodeStacktraces.value + if !ctx.settings.XnoDecodeStacktraces.value && handleRecursive.underlyingStackOverflowOrNull(ex) != null then throw StackSizeExceeded(mdef) else @@ -924,7 +924,7 @@ class TreePickler(pickler: TastyPickler, attributes: Attributes) { em"""Recursion limit exceeded while pickling ${ex.mdef} |in ${ex.mdef.symbol.showLocated}. |You could try to increase the stacksize using the -Xss JVM option. - |For the unprocessed stack trace, compile with -Yno-decode-stacktraces.""", + |For the unprocessed stack trace, compile with -Xno-decode-stacktraces.""", ex.mdef.srcPos) def missing = forwardSymRefs.keysIterator diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala index 19c22c6bb3d0..04d19f2f8821 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala @@ -986,8 +986,8 @@ class TreeUnpickler(reader: TastyReader, if !sym.isType && !sym.is(ParamAccessor) then sym.info = ta.avoidPrivateLeaks(sym) - if (ctx.settings.YreadComments.value) { - assert(ctx.docCtx.isDefined, "`-Yread-docs` enabled, but no `docCtx` is set.") + if (ctx.settings.XreadComments.value) { + assert(ctx.docCtx.isDefined, "`-Xread-docs` enabled, but no `docCtx` is set.") commentUnpicklerOpt.foreach { commentUnpickler => val comment = commentUnpickler.commentAt(start) ctx.docCtx.get.addDocstring(tree.symbol, comment) diff --git a/compiler/src/dotty/tools/dotc/decompiler/IDEDecompilerDriver.scala b/compiler/src/dotty/tools/dotc/decompiler/IDEDecompilerDriver.scala index c1bd6b6778fd..18c5ceb5f346 100644 --- a/compiler/src/dotty/tools/dotc/decompiler/IDEDecompilerDriver.scala +++ b/compiler/src/dotty/tools/dotc/decompiler/IDEDecompilerDriver.scala @@ -19,7 +19,7 @@ class IDEDecompilerDriver(val settings: List[String]) extends dotc.Driver { private val myInitCtx: Context = { val rootCtx = initCtx.fresh.addMode(Mode.Interactive | Mode.ReadPositions) - rootCtx.setSetting(rootCtx.settings.YreadComments, true) + rootCtx.setSetting(rootCtx.settings.XreadComments, true) rootCtx.setSetting(rootCtx.settings.YretainTrees, true) rootCtx.setSetting(rootCtx.settings.fromTasty, true) val ctx = setup(settings.toArray :+ "dummy.scala", rootCtx).get._2 diff --git a/compiler/src/dotty/tools/dotc/fromtasty/ReadTasty.scala b/compiler/src/dotty/tools/dotc/fromtasty/ReadTasty.scala index 74010b3f64d1..f13bcdf00b34 100644 --- a/compiler/src/dotty/tools/dotc/fromtasty/ReadTasty.scala +++ b/compiler/src/dotty/tools/dotc/fromtasty/ReadTasty.scala @@ -48,11 +48,11 @@ class ReadTasty extends Phase { if (cls.rootTree.isEmpty) None else { val attributes = unpickler.tastyAttributes - if attributes.isJava && !ctx.settings.YjavaTasty.value then - // filter out Java compilation units if -Yjava-tasty is not set + if attributes.isJava && !ctx.settings.XjavaTasty.value then + // filter out Java compilation units if -Xjava-tasty is not set None - else if attributes.isOutline && !ctx.settings.YallowOutlineFromTasty.value then - cannotUnpickle("it contains outline signatures and -Yallow-outline-from-tasty is not set.") + else if attributes.isOutline && !ctx.settings.XallowOutlineFromTasty.value then + cannotUnpickle("it contains outline signatures and -Xallow-outline-from-tasty is not set.") else val unit = CompilationUnit(cls, cls.rootTree, forceTrees = true) unit.pickled += (cls -> (() => unpickler.unpickler.bytes)) diff --git a/compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala b/compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala index 8f42c62cb3b0..673874ae2769 100644 --- a/compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala +++ b/compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala @@ -33,8 +33,8 @@ class InteractiveDriver(val settings: List[String]) extends Driver { private val myInitCtx: Context = { val rootCtx = initCtx.fresh.addMode(Mode.ReadPositions).addMode(Mode.Interactive) rootCtx.setSetting(rootCtx.settings.YretainTrees, true) - rootCtx.setSetting(rootCtx.settings.YcookComments, true) - rootCtx.setSetting(rootCtx.settings.YreadComments, true) + rootCtx.setSetting(rootCtx.settings.XcookComments, true) + rootCtx.setSetting(rootCtx.settings.XreadComments, true) val ctx = setup(settings.toArray, rootCtx) match case Some((_, ctx)) => ctx case None => rootCtx diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 2f3daa79fb07..916fd2b30ed7 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -1614,7 +1614,7 @@ object Parsers { imods &~= Given syntaxError(em"context function types require at least one parameter", paramSpan) FunctionWithMods(params, resultType, imods, erasedArgs.toList) - else if !ctx.settings.YkindProjector.isDefault then + else if !ctx.settings.XkindProjector.isDefault then val (newParams :+ newResultType, tparams) = replaceKindProjectorPlaceholders(params :+ resultType): @unchecked lambdaAbstract(tparams, Function(newParams, newResultType)) else @@ -1741,7 +1741,7 @@ object Parsers { val isVarianceAnnotated = name.startsWith("+") || name.startsWith("-") // We remove the variance marker from the name without passing along the specified variance at all // The real variance will be inferred at a later stage but may contradict the variance specified, - // This is ok, because `-Ykind-projector` is for cross-compiling existing Scala 2 code, not for writing new code, + // This is ok, because `-Xkind-projector` is for cross-compiling existing Scala 2 code, not for writing new code, // we may assume that variance annotations have already been checked by the Scala 2 compiler. val unannotatedName = if (isVarianceAnnotated) name.mapLast(_.drop(1)) else name TypeDef(unannotatedName, WildcardTypeBoundsTree()).withFlags(Param) @@ -1758,7 +1758,7 @@ object Parsers { Ident(name) } - val uscores = ctx.settings.YkindProjector.value == "underscores" + val uscores = ctx.settings.XkindProjector.value == "underscores" val newParams = params.mapConserve { case param @ Ident(tpnme.raw.STAR | tpnme.raw.MINUS_STAR | tpnme.raw.PLUS_STAR) => addParam() case param @ Ident(tpnme.USCOREkw | tpnme.raw.MINUS_USCORE | tpnme.raw.PLUS_USCORE) if uscores => addParam() @@ -1944,7 +1944,7 @@ object Parsers { if isSimpleLiteral then SingletonTypeTree(simpleLiteral()) else if in.token == USCORE then - if ctx.settings.YkindProjector.value == "underscores" then + if ctx.settings.XkindProjector.value == "underscores" then val start = in.skipToken() Ident(tpnme.USCOREkw).withSpan(Span(start, in.lastOffset, start)) else @@ -1960,7 +1960,7 @@ object Parsers { typeBounds().withSpan(Span(start, in.lastOffset, start)) // Allow symbols -_ and +_ through for compatibility with code written using kind-projector in Scala 3 underscore mode. // While these signify variant type parameters in Scala 2 + kind-projector, we ignore their variance markers since variance is inferred. - else if (isIdent(nme.MINUS) || isIdent(nme.PLUS)) && in.lookahead.token == USCORE && ctx.settings.YkindProjector.value == "underscores" then + else if (isIdent(nme.MINUS) || isIdent(nme.PLUS)) && in.lookahead.token == USCORE && ctx.settings.XkindProjector.value == "underscores" then val identName = in.name.toTypeName ++ nme.USCOREkw val start = in.skipToken() in.nextToken() @@ -2012,7 +2012,7 @@ object Parsers { val applied = rejectWildcardType(t) val args = typeArgs(namedOK = false, wildOK = true) - if (!ctx.settings.YkindProjector.isDefault) { + if (!ctx.settings.XkindProjector.isDefault) { def fail(): Tree = { syntaxError( em"λ requires a single argument of the form X => ... or (X, Y) => ...", @@ -2044,7 +2044,7 @@ object Parsers { } }) case _ => - if (!ctx.settings.YkindProjector.isDefault) { + if (!ctx.settings.XkindProjector.isDefault) { t match { case Tuple(params) => val (newParams, tparams) = replaceKindProjectorPlaceholders(params) diff --git a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala index 3f9e8ca6532e..831d31d6fa6e 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala @@ -174,7 +174,7 @@ object Scanners { } class Scanner(source: SourceFile, override val startFrom: Offset = 0, profile: Profile = NoProfile, allowIndent: Boolean = true)(using Context) extends ScannerCommon(source) { - val keepComments = !ctx.settings.YdropComments.value + val keepComments = !ctx.settings.XdropComments.value /** A switch whether operators at the start of lines can be infix operators */ private[Scanners] var allowLeadingInfixOperators = true diff --git a/compiler/src/dotty/tools/dotc/report.scala b/compiler/src/dotty/tools/dotc/report.scala index 10b0023992fe..1d8ca5f208fa 100644 --- a/compiler/src/dotty/tools/dotc/report.scala +++ b/compiler/src/dotty/tools/dotc/report.scala @@ -146,7 +146,7 @@ object report: // Should only be called from Run#enrichErrorMessage. def enrichErrorMessage(errorMessage: String)(using Context): String = - if ctx.settings.YnoEnrichErrorMessages.value then errorMessage + if ctx.settings.XnoEnrichErrorMessages.value then errorMessage else try enrichErrorMessage1(errorMessage) catch case _: Throwable => errorMessage // don't introduce new errors trying to report errors, so swallow exceptions @@ -171,7 +171,7 @@ object report: | An unhandled exception was thrown in the compiler. | Please file a crash report here: | https://github.com/scala/scala3/issues/new/choose - | For non-enriched exceptions, compile with -Yno-enrich-error-messages. + | For non-enriched exceptions, compile with -Xno-enrich-error-messages. | |$info1 |""".stripMargin diff --git a/compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala b/compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala index 9bbac381efab..75f04908ac55 100644 --- a/compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala +++ b/compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala @@ -52,13 +52,13 @@ class ExtractAPI extends Phase { override def description: String = ExtractAPI.description override def isRunnable(using Context): Boolean = { - super.isRunnable && (ctx.runZincPhases || ctx.settings.YjavaTasty.value) + super.isRunnable && (ctx.runZincPhases || ctx.settings.XjavaTasty.value) } // Check no needed. Does not transform trees override def isCheckable: Boolean = false - // when `-Yjava-tasty` is set we actually want to run this phase on Java sources + // when `-Xjava-tasty` is set we actually want to run this phase on Java sources override def skipIfJava(using Context): Boolean = false // SuperAccessors need to be part of the API (see the scripted test @@ -79,8 +79,8 @@ class ExtractAPI extends Phase { units // still run the phase for the side effects (writing TASTy files to -Yearly-tasty-output) if doZincCallback then ctx.withIncCallback(recordNonLocalClasses(nonLocalClassSymbols, _)) - if ctx.settings.YjavaTasty.value then - units0.filterNot(_.typedAsJava) // remove java sources, this is the terminal phase when `-Yjava-tasty` is set + if ctx.settings.XjavaTasty.value then + units0.filterNot(_.typedAsJava) // remove java sources, this is the terminal phase when `-Xjava-tasty` is set else units0 end runOn diff --git a/compiler/src/dotty/tools/dotc/sbt/ExtractDependencies.scala b/compiler/src/dotty/tools/dotc/sbt/ExtractDependencies.scala index 352636f681c3..dfff5971889e 100644 --- a/compiler/src/dotty/tools/dotc/sbt/ExtractDependencies.scala +++ b/compiler/src/dotty/tools/dotc/sbt/ExtractDependencies.scala @@ -64,7 +64,7 @@ class ExtractDependencies extends Phase { // Check no needed. Does not transform trees override def isCheckable: Boolean = false - // when `-Yjava-tasty` is set we actually want to run this phase on Java sources + // when `-Xjava-tasty` is set we actually want to run this phase on Java sources override def skipIfJava(using Context): Boolean = false // This phase should be run directly after `Frontend`, if it is run after diff --git a/compiler/src/dotty/tools/dotc/transform/CookComments.scala b/compiler/src/dotty/tools/dotc/transform/CookComments.scala index d443e31fdc39..5dec0fff1e39 100644 --- a/compiler/src/dotty/tools/dotc/transform/CookComments.scala +++ b/compiler/src/dotty/tools/dotc/transform/CookComments.scala @@ -12,7 +12,7 @@ class CookComments extends MegaPhase.MiniPhase { override def description: String = CookComments.description override def transformTypeDef(tree: tpd.TypeDef)(using Context): tpd.Tree = { - if (ctx.settings.YcookComments.value && tree.isClassDef) { + if (ctx.settings.XcookComments.value && tree.isClassDef) { val cls = tree.symbol val cookingCtx = ctx.localContext(tree, cls).setNewScope val template = tree.rhs.asInstanceOf[tpd.Template] diff --git a/compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala b/compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala index c75ac9982317..217c843c4e50 100644 --- a/compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala +++ b/compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala @@ -445,7 +445,7 @@ object GenericSignatures { } } - private def needsJavaSig(tp: Type, throwsArgs: List[Type])(using Context): Boolean = !ctx.settings.YnoGenericSig.value && { + private def needsJavaSig(tp: Type, throwsArgs: List[Type])(using Context): Boolean = !ctx.settings.XnoGenericSig.value && { def needs(tp: Type) = (new NeedsSigCollector).apply(false, tp) needs(tp) || throwsArgs.exists(needs) } diff --git a/compiler/src/dotty/tools/dotc/transform/Pickler.scala b/compiler/src/dotty/tools/dotc/transform/Pickler.scala index 8bb396ca4081..7507c17cdb74 100644 --- a/compiler/src/dotty/tools/dotc/transform/Pickler.scala +++ b/compiler/src/dotty/tools/dotc/transform/Pickler.scala @@ -198,7 +198,7 @@ class Pickler extends Phase { // we do not want to pickle `.betasty` if do not plan to actually create the // betasty file (as signified by the -Ybest-effort option) - // when `-Yjava-tasty` is set we actually want to run this phase on Java sources + // when `-Xjava-tasty` is set we actually want to run this phase on Java sources override def skipIfJava(using Context): Boolean = false private def output(name: String, msg: String) = { @@ -286,8 +286,8 @@ class Pickler extends Phase { util.SourceFile.relativePath(unit.source, reference) val isJavaAttr = unit.isJava // we must always set JAVAattr when pickling Java sources if isJavaAttr then - // assert that Java sources didn't reach Pickler without `-Yjava-tasty`. - assert(ctx.settings.YjavaTasty.value, "unexpected Java source file without -Yjava-tasty") + // assert that Java sources didn't reach Pickler without `-Xjava-tasty`. + assert(ctx.settings.XjavaTasty.value, "unexpected Java source file without -Xjava-tasty") val isOutline = isJavaAttr // TODO: later we may want outline for Scala sources too val attributes = Attributes( sourceFile = sourceRelativePath, @@ -326,7 +326,7 @@ class Pickler extends Phase { unit.source, tree :: Nil, positionWarnings, scratch.positionBuffer, scratch.pickledIndices) - if !ctx.settings.YdropComments.value then + if !ctx.settings.XdropComments.value then CommentPickler.pickleComments( pickler, treePkl.buf.addrOfTree, treePkl.docString, tree, scratch.commentBuffer) @@ -403,7 +403,7 @@ class Pickler extends Phase { runPhase(_()) if ctx.settings.YtestPickler.value then val ctx2 = ctx.fresh - .setSetting(ctx.settings.YreadComments, true) + .setSetting(ctx.settings.XreadComments, true) .setSetting(ctx.settings.YshowPrintErrors, true) testUnpickler( using ctx2 diff --git a/compiler/src/dotty/tools/dotc/typer/TyperPhase.scala b/compiler/src/dotty/tools/dotc/typer/TyperPhase.scala index f7afc7a7e0a7..0c63f5b4ecb1 100644 --- a/compiler/src/dotty/tools/dotc/typer/TyperPhase.scala +++ b/compiler/src/dotty/tools/dotc/typer/TyperPhase.scala @@ -59,7 +59,7 @@ class TyperPhase(addRootImports: Boolean = true) extends Phase { } protected def discardAfterTyper(unit: CompilationUnit)(using Context): Boolean = - (unit.isJava && !ctx.settings.YjavaTasty.value) || unit.suspended + (unit.isJava && !ctx.settings.XjavaTasty.value) || unit.suspended override val subPhases: List[SubPhase] = List( SubPhase("indexing"), SubPhase("typechecking"), SubPhase("checkingJava")) diff --git a/compiler/src/dotty/tools/repl/ReplDriver.scala b/compiler/src/dotty/tools/repl/ReplDriver.scala index f8bba2f59fe1..121d00bcf8b3 100644 --- a/compiler/src/dotty/tools/repl/ReplDriver.scala +++ b/compiler/src/dotty/tools/repl/ReplDriver.scala @@ -82,8 +82,8 @@ class ReplDriver(settings: Array[String], /** Create a fresh and initialized context with IDE mode enabled */ private def initialCtx(settings: List[String]) = { val rootCtx = initCtx.fresh.addMode(Mode.ReadPositions | Mode.Interactive) - rootCtx.setSetting(rootCtx.settings.YcookComments, true) - rootCtx.setSetting(rootCtx.settings.YreadComments, true) + rootCtx.setSetting(rootCtx.settings.XcookComments, true) + rootCtx.setSetting(rootCtx.settings.XreadComments, true) setupRootCtx(this.settings ++ settings, rootCtx) } diff --git a/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala b/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala index eb300a0512b5..517adff17991 100644 --- a/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala +++ b/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala @@ -43,7 +43,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler import tpd.* private val xCheckMacro: Boolean = ctx.settings.XcheckMacros.value - private val yDebugMacro: Boolean = ctx.settings.YdebugMacros.value + private val yDebugMacro: Boolean = ctx.settings.XdebugMacros.value extension [T](self: scala.quoted.Expr[T]) def show: String = diff --git a/compiler/test/dotty/tools/dotc/config/ScalaSettingsTests.scala b/compiler/test/dotty/tools/dotc/config/ScalaSettingsTests.scala index b2de0d6423df..3c0b165b6457 100644 --- a/compiler/test/dotty/tools/dotc/config/ScalaSettingsTests.scala +++ b/compiler/test/dotty/tools/dotc/config/ScalaSettingsTests.scala @@ -88,6 +88,59 @@ class ScalaSettingsTests: val nowr = new Diagnostic.Warning("This is a problem.".toMessage, util.NoSourcePosition) assertEquals(Action.Silent, sut.action(nowr)) + @Test def `Lifted options are correctly mapped to their replacements`: Unit = + def createTestCase(oldSetting: Setting[_], newSetting: Setting[_], value: String = "") = + s"${oldSetting.name}$value" -> newSetting + + val settings = ScalaSettings + List( + createTestCase(settings.YtermConflict , settings.XtermConflict, ":package"), + createTestCase(settings.YnoGenericSig , settings.XnoGenericSig), + createTestCase(settings.Ydumpclasses , settings.Xdumpclasses,":./"), + createTestCase(settings.YjarCompressionLevel , settings.XjarCompressionLevel,":0"), + createTestCase(settings.YkindProjector , settings.XkindProjector, ":underscores"), + createTestCase(settings.YdropComments , settings.XdropComments), + createTestCase(settings.YcookComments , settings.XcookComments), + createTestCase(settings.YreadComments , settings.XreadComments), + createTestCase(settings.YnoDecodeStacktraces , settings.XnoDecodeStacktraces), + createTestCase(settings.YnoEnrichErrorMessages, settings.XnoEnrichErrorMessages), + createTestCase(settings.YdebugMacros , settings.XdebugMacros), + createTestCase(settings.YjavaTasty , settings.XjavaTasty), + createTestCase(settings.YearlyTastyOutput , settings.XearlyTastyOutput, ":./"), + createTestCase(settings.YallowOutlineFromTasty, settings.XallowOutlineFromTasty), + ).map: (deprecatedArgument, newSetting) => + val args = List(deprecatedArgument) + val argSummary = ArgsSummary(settings.defaultState, args, errors = Nil, warnings = Nil) + val conf = settings.processArguments(argSummary, processAll = true, skipped = Nil) + assert(!newSetting.isDefaultIn(conf.sstate), s"Setting $deprecatedArgument was not forwarded to ${newSetting.name}") + + @Test def `Lifted options aliases are correctly mapped to their replacements`: Unit = + def createTestCase(oldSetting: Setting[_], newSetting: Setting[_], value: String = "") = + oldSetting.aliases.map: alias => + s"$alias$value" -> newSetting + + val settings = ScalaSettings + List( + createTestCase(settings.YtermConflict , settings.XtermConflict, ":package"), + createTestCase(settings.YnoGenericSig , settings.XnoGenericSig), + createTestCase(settings.Ydumpclasses , settings.Xdumpclasses,":./"), + createTestCase(settings.YjarCompressionLevel , settings.XjarCompressionLevel,":0"), + createTestCase(settings.YkindProjector , settings.XkindProjector, ":underscores"), + createTestCase(settings.YdropComments , settings.XdropComments), + createTestCase(settings.YcookComments , settings.XcookComments), + createTestCase(settings.YreadComments , settings.XreadComments), + createTestCase(settings.YnoDecodeStacktraces , settings.XnoDecodeStacktraces), + createTestCase(settings.YnoEnrichErrorMessages, settings.XnoEnrichErrorMessages), + createTestCase(settings.YdebugMacros , settings.XdebugMacros), + createTestCase(settings.YjavaTasty , settings.XjavaTasty), + createTestCase(settings.YearlyTastyOutput , settings.XearlyTastyOutput, ":./"), + createTestCase(settings.YallowOutlineFromTasty, settings.XallowOutlineFromTasty), + ).flatten.map: (deprecatedArgument, newSetting) => + val args = List(deprecatedArgument) + val argSummary = ArgsSummary(settings.defaultState, args, errors = Nil, warnings = Nil) + val conf = settings.processArguments(argSummary, processAll = true, skipped = Nil) + assert(!newSetting.isDefaultIn(conf.sstate), s"Setting alias $deprecatedArgument was not forwarded to ${newSetting.name}") + @Test def `i18367 rightmost WConf flags take precedence over flags to the left`: Unit = import reporting.{Action, Diagnostic} val sets = ScalaSettings diff --git a/docs/_docs/reference/changed-features/wildcards.md b/docs/_docs/reference/changed-features/wildcards.md index ac7235770e36..3ed7e01cb535 100644 --- a/docs/_docs/reference/changed-features/wildcards.md +++ b/docs/_docs/reference/changed-features/wildcards.md @@ -35,16 +35,16 @@ A step-by-step migration is made possible with the following measures: 4. Some deprecation warnings are already available under the `-source future` setting. To smooth the transition for codebases that use kind-projector, we adopt the following measures under the command line -option `-Ykind-projector`: +option `-Xkind-projector`: 1. In Scala 3.0, `*` is available as a type parameter placeholder. 2. In Scala 3.2, `*` is deprecated in favor of `_`. A `-rewrite` option is available to rewrite one to the other. 3. In Scala 3.3, `*` is removed again, and all type parameter placeholders will be expressed with `_`. -These rules make it possible to cross-build between Scala 2 using the kind projector plugin and Scala 3.0 - 3.2 using the compiler option `-Ykind-projector`. +These rules make it possible to cross-build between Scala 2 using the kind projector plugin and Scala 3.0 - 3.2 using the compiler option `-Xkind-projector`. There is also a migration path for users that want a one-time transition to syntax with `_` as a type parameter placeholder. -With option `-Ykind-projector:underscores` Scala 3 will regard `_` as a type parameter placeholder, leaving `?` as the only syntax for wildcards. +With option `-Xkind-projector:underscores` Scala 3 will regard `_` as a type parameter placeholder, leaving `?` as the only syntax for wildcards. To cross-compile with old Scala 2 sources, while using `_` a placeholder, you must use options `-Xsource:3 -P:kind-projector:underscore-placeholders` together with a recent version of kind-projector (`0.13` and higher) and most recent versions of Scala 2 (`2.13.5` and higher and `2.12.14` and higher) diff --git a/docs/_spec/APPLIEDreference/changed-features/wildcards.md b/docs/_spec/APPLIEDreference/changed-features/wildcards.md index 0d3e13c3d7e0..64d1de69e526 100644 --- a/docs/_spec/APPLIEDreference/changed-features/wildcards.md +++ b/docs/_spec/APPLIEDreference/changed-features/wildcards.md @@ -35,16 +35,16 @@ A step-by-step migration is made possible with the following measures: 4. The Scala 3.1 behavior is already available today under the `-source future` setting. To smooth the transition for codebases that use kind-projector, we adopt the following measures under the command line -option `-Ykind-projector`: +option `-Xkind-projector`: 1. In Scala 3.0, `*` is available as a type parameter placeholder. 2. In Scala 3.2, `*` is deprecated in favor of `_`. A `-rewrite` option is available to rewrite one to the other. 3. In Scala 3.3, `*` is removed again, and all type parameter placeholders will be expressed with `_`. -These rules make it possible to cross build between Scala 2 using the kind projector plugin and Scala 3.0 - 3.2 using the compiler option `-Ykind-projector`. +These rules make it possible to cross build between Scala 2 using the kind projector plugin and Scala 3.0 - 3.2 using the compiler option `-Xkind-projector`. There is also a migration path for users that want a one-time transition to syntax with `_` as a type parameter placeholder. -With option `-Ykind-projector:underscores` Scala 3 will regard `_` as a type parameter placeholder, leaving `?` as the only syntax for wildcards. +With option `-Xkind-projector:underscores` Scala 3 will regard `_` as a type parameter placeholder, leaving `?` as the only syntax for wildcards. To cross-compile with old Scala 2 sources, while using `_` a placeholder, you must use options `-Xsource:3 -P:kind-projector:underscore-placeholders` together with a recent version of kind-projector (`0.13` and higher) and most recent versions of Scala 2 (`2.13.5` and higher and `2.12.14` and higher) diff --git a/sbt-test/pipelining/Yearly-tasty-output-inline/a/src/main/scala/a/A.scala b/sbt-test/pipelining/Xearly-tasty-output-inline/a/src/main/scala/a/A.scala similarity index 100% rename from sbt-test/pipelining/Yearly-tasty-output-inline/a/src/main/scala/a/A.scala rename to sbt-test/pipelining/Xearly-tasty-output-inline/a/src/main/scala/a/A.scala diff --git a/sbt-test/pipelining/Yearly-tasty-output-inline/b/src/main/scala/b/B.scala b/sbt-test/pipelining/Xearly-tasty-output-inline/b/src/main/scala/b/B.scala similarity index 100% rename from sbt-test/pipelining/Yearly-tasty-output-inline/b/src/main/scala/b/B.scala rename to sbt-test/pipelining/Xearly-tasty-output-inline/b/src/main/scala/b/B.scala diff --git a/sbt-test/pipelining/Yearly-tasty-output-inline/build.sbt b/sbt-test/pipelining/Xearly-tasty-output-inline/build.sbt similarity index 90% rename from sbt-test/pipelining/Yearly-tasty-output-inline/build.sbt rename to sbt-test/pipelining/Xearly-tasty-output-inline/build.sbt index e350fa7e7def..8ca1f4df759e 100644 --- a/sbt-test/pipelining/Yearly-tasty-output-inline/build.sbt +++ b/sbt-test/pipelining/Xearly-tasty-output-inline/build.sbt @@ -4,7 +4,7 @@ // defines a inline method. lazy val a = project.in(file("a")) .settings( - scalacOptions ++= Seq("-Yearly-tasty-output", ((ThisBuild / baseDirectory).value / "a-early.jar").toString), + scalacOptions ++= Seq("-Xearly-tasty-output", ((ThisBuild / baseDirectory).value / "a-early.jar").toString), scalacOptions += "-Ycheck:all", ) diff --git a/sbt-test/pipelining/Yearly-tasty-output-inline/project/DottyInjectedPlugin.scala b/sbt-test/pipelining/Xearly-tasty-output-inline/project/DottyInjectedPlugin.scala similarity index 100% rename from sbt-test/pipelining/Yearly-tasty-output-inline/project/DottyInjectedPlugin.scala rename to sbt-test/pipelining/Xearly-tasty-output-inline/project/DottyInjectedPlugin.scala diff --git a/sbt-test/pipelining/Yearly-tasty-output-inline/test b/sbt-test/pipelining/Xearly-tasty-output-inline/test similarity index 100% rename from sbt-test/pipelining/Yearly-tasty-output-inline/test rename to sbt-test/pipelining/Xearly-tasty-output-inline/test diff --git a/sbt-test/pipelining/Yearly-tasty-output/a/src/main/scala/a/A.scala b/sbt-test/pipelining/Xearly-tasty-output/a/src/main/scala/a/A.scala similarity index 100% rename from sbt-test/pipelining/Yearly-tasty-output/a/src/main/scala/a/A.scala rename to sbt-test/pipelining/Xearly-tasty-output/a/src/main/scala/a/A.scala diff --git a/sbt-test/pipelining/Yearly-tasty-output/b-early-out/.keep b/sbt-test/pipelining/Xearly-tasty-output/b-early-out/.keep similarity index 100% rename from sbt-test/pipelining/Yearly-tasty-output/b-early-out/.keep rename to sbt-test/pipelining/Xearly-tasty-output/b-early-out/.keep diff --git a/sbt-test/pipelining/Yearly-tasty-output/b/src/main/scala/b/B.scala b/sbt-test/pipelining/Xearly-tasty-output/b/src/main/scala/b/B.scala similarity index 100% rename from sbt-test/pipelining/Yearly-tasty-output/b/src/main/scala/b/B.scala rename to sbt-test/pipelining/Xearly-tasty-output/b/src/main/scala/b/B.scala diff --git a/sbt-test/pipelining/Yearly-tasty-output/build.sbt b/sbt-test/pipelining/Xearly-tasty-output/build.sbt similarity index 87% rename from sbt-test/pipelining/Yearly-tasty-output/build.sbt rename to sbt-test/pipelining/Xearly-tasty-output/build.sbt index 5cfe30936ea9..739f6cc8c31e 100644 --- a/sbt-test/pipelining/Yearly-tasty-output/build.sbt +++ b/sbt-test/pipelining/Xearly-tasty-output/build.sbt @@ -4,14 +4,14 @@ // early out is a jar lazy val a = project.in(file("a")) .settings( - scalacOptions ++= Seq("-Yearly-tasty-output", ((ThisBuild / baseDirectory).value / "a-early.jar").toString), + scalacOptions ++= Seq("-Xearly-tasty-output", ((ThisBuild / baseDirectory).value / "a-early.jar").toString), scalacOptions += "-Ycheck:all", ) // early out is a directory lazy val b = project.in(file("b")) .settings( - scalacOptions ++= Seq("-Yearly-tasty-output", ((ThisBuild / baseDirectory).value / "b-early-out").toString), + scalacOptions ++= Seq("-Xearly-tasty-output", ((ThisBuild / baseDirectory).value / "b-early-out").toString), scalacOptions += "-Ycheck:all", ) diff --git a/sbt-test/pipelining/Yearly-tasty-output/c/src/main/scala/c/C.scala b/sbt-test/pipelining/Xearly-tasty-output/c/src/main/scala/c/C.scala similarity index 100% rename from sbt-test/pipelining/Yearly-tasty-output/c/src/main/scala/c/C.scala rename to sbt-test/pipelining/Xearly-tasty-output/c/src/main/scala/c/C.scala diff --git a/sbt-test/pipelining/Yearly-tasty-output/project/DottyInjectedPlugin.scala b/sbt-test/pipelining/Xearly-tasty-output/project/DottyInjectedPlugin.scala similarity index 100% rename from sbt-test/pipelining/Yearly-tasty-output/project/DottyInjectedPlugin.scala rename to sbt-test/pipelining/Xearly-tasty-output/project/DottyInjectedPlugin.scala diff --git a/sbt-test/pipelining/Yearly-tasty-output/test b/sbt-test/pipelining/Xearly-tasty-output/test similarity index 100% rename from sbt-test/pipelining/Yearly-tasty-output/test rename to sbt-test/pipelining/Xearly-tasty-output/test diff --git a/sbt-test/pipelining/Yjava-tasty-annotation/a/src/main/scala/a/A.java b/sbt-test/pipelining/Xjava-tasty-annotation/a/src/main/scala/a/A.java similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-annotation/a/src/main/scala/a/A.java rename to sbt-test/pipelining/Xjava-tasty-annotation/a/src/main/scala/a/A.java diff --git a/sbt-test/pipelining/Yjava-tasty-annotation/a/src/main/scala/a/package.scala b/sbt-test/pipelining/Xjava-tasty-annotation/a/src/main/scala/a/package.scala similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-annotation/a/src/main/scala/a/package.scala rename to sbt-test/pipelining/Xjava-tasty-annotation/a/src/main/scala/a/package.scala diff --git a/sbt-test/pipelining/Yjava-tasty-annotation/b-alt/.keep b/sbt-test/pipelining/Xjava-tasty-annotation/b-alt/.keep similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-annotation/b-alt/.keep rename to sbt-test/pipelining/Xjava-tasty-annotation/b-alt/.keep diff --git a/sbt-test/pipelining/Yjava-tasty-annotation/b/src/main/scala/b/B.scala b/sbt-test/pipelining/Xjava-tasty-annotation/b/src/main/scala/b/B.scala similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-annotation/b/src/main/scala/b/B.scala rename to sbt-test/pipelining/Xjava-tasty-annotation/b/src/main/scala/b/B.scala diff --git a/sbt-test/pipelining/Yjava-tasty-annotation/build.sbt b/sbt-test/pipelining/Xjava-tasty-annotation/build.sbt similarity index 87% rename from sbt-test/pipelining/Yjava-tasty-annotation/build.sbt rename to sbt-test/pipelining/Xjava-tasty-annotation/build.sbt index 20a13d7d4ba0..440ef8eced59 100644 --- a/sbt-test/pipelining/Yjava-tasty-annotation/build.sbt +++ b/sbt-test/pipelining/Xjava-tasty-annotation/build.sbt @@ -1,7 +1,7 @@ lazy val a = project.in(file("a")) .settings( - scalacOptions += "-Yjava-tasty", // enable pickling of java signatures - scalacOptions ++= Seq("-Yearly-tasty-output", ((ThisBuild / baseDirectory).value / "a-annotation-java-tasty.jar").toString), + scalacOptions += "-Xjava-tasty", // enable pickling of java signatures + scalacOptions ++= Seq("-Xearly-tasty-output", ((ThisBuild / baseDirectory).value / "a-annotation-java-tasty.jar").toString), scalacOptions += "-Ycheck:all", Compile / classDirectory := ((ThisBuild / baseDirectory).value / "a-annotation-classes"), // send classfiles to a different directory ) diff --git a/sbt-test/pipelining/Yjava-tasty-annotation/project/DottyInjectedPlugin.scala b/sbt-test/pipelining/Xjava-tasty-annotation/project/DottyInjectedPlugin.scala similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-annotation/project/DottyInjectedPlugin.scala rename to sbt-test/pipelining/Xjava-tasty-annotation/project/DottyInjectedPlugin.scala diff --git a/sbt-test/pipelining/Yjava-tasty-annotation/test b/sbt-test/pipelining/Xjava-tasty-annotation/test similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-annotation/test rename to sbt-test/pipelining/Xjava-tasty-annotation/test diff --git a/sbt-test/pipelining/Yjava-tasty-enum/a/src/main/scala/a/A.java b/sbt-test/pipelining/Xjava-tasty-enum/a/src/main/scala/a/A.java similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-enum/a/src/main/scala/a/A.java rename to sbt-test/pipelining/Xjava-tasty-enum/a/src/main/scala/a/A.java diff --git a/sbt-test/pipelining/Yjava-tasty-enum/a/src/main/scala/a/package.scala b/sbt-test/pipelining/Xjava-tasty-enum/a/src/main/scala/a/package.scala similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-enum/a/src/main/scala/a/package.scala rename to sbt-test/pipelining/Xjava-tasty-enum/a/src/main/scala/a/package.scala diff --git a/sbt-test/pipelining/Yjava-tasty-enum/b-alt/.keep b/sbt-test/pipelining/Xjava-tasty-enum/b-alt/.keep similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-enum/b-alt/.keep rename to sbt-test/pipelining/Xjava-tasty-enum/b-alt/.keep diff --git a/sbt-test/pipelining/Yjava-tasty-enum/b/src/main/scala/b/B.scala b/sbt-test/pipelining/Xjava-tasty-enum/b/src/main/scala/b/B.scala similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-enum/b/src/main/scala/b/B.scala rename to sbt-test/pipelining/Xjava-tasty-enum/b/src/main/scala/b/B.scala diff --git a/sbt-test/pipelining/Yjava-tasty-enum/build.sbt b/sbt-test/pipelining/Xjava-tasty-enum/build.sbt similarity index 92% rename from sbt-test/pipelining/Yjava-tasty-enum/build.sbt rename to sbt-test/pipelining/Xjava-tasty-enum/build.sbt index 2083003d9ebe..5adbe6ec992e 100644 --- a/sbt-test/pipelining/Yjava-tasty-enum/build.sbt +++ b/sbt-test/pipelining/Xjava-tasty-enum/build.sbt @@ -1,8 +1,8 @@ lazy val a = project.in(file("a")) .settings( compileOrder := CompileOrder.Mixed, // ensure we send java sources to Scala compiler - scalacOptions += "-Yjava-tasty", // enable pickling of java signatures - scalacOptions ++= Seq("-Yearly-tasty-output", ((ThisBuild / baseDirectory).value / "a-enum-java-tasty.jar").toString), + scalacOptions += "-Xjava-tasty", // enable pickling of java signatures + scalacOptions ++= Seq("-Xearly-tasty-output", ((ThisBuild / baseDirectory).value / "a-enum-java-tasty.jar").toString), scalacOptions += "-Ycheck:all", Compile / classDirectory := ((ThisBuild / baseDirectory).value / "a-enum-classes"), // send classfiles to a different directory ) diff --git a/sbt-test/pipelining/Yjava-tasty-enum/project/DottyInjectedPlugin.scala b/sbt-test/pipelining/Xjava-tasty-enum/project/DottyInjectedPlugin.scala similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-enum/project/DottyInjectedPlugin.scala rename to sbt-test/pipelining/Xjava-tasty-enum/project/DottyInjectedPlugin.scala diff --git a/sbt-test/pipelining/Yjava-tasty-enum/test b/sbt-test/pipelining/Xjava-tasty-enum/test similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-enum/test rename to sbt-test/pipelining/Xjava-tasty-enum/test diff --git a/sbt-test/pipelining/Yjava-tasty-from-tasty/a/src/main/scala/a/A.java b/sbt-test/pipelining/Xjava-tasty-from-tasty/a/src/main/scala/a/A.java similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-from-tasty/a/src/main/scala/a/A.java rename to sbt-test/pipelining/Xjava-tasty-from-tasty/a/src/main/scala/a/A.java diff --git a/sbt-test/pipelining/Yjava-tasty-from-tasty/a/src/main/scala/a/package.scala b/sbt-test/pipelining/Xjava-tasty-from-tasty/a/src/main/scala/a/package.scala similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-from-tasty/a/src/main/scala/a/package.scala rename to sbt-test/pipelining/Xjava-tasty-from-tasty/a/src/main/scala/a/package.scala diff --git a/sbt-test/pipelining/Yjava-tasty-from-tasty/a_from_tasty/.keep b/sbt-test/pipelining/Xjava-tasty-from-tasty/a_from_tasty/.keep similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-from-tasty/a_from_tasty/.keep rename to sbt-test/pipelining/Xjava-tasty-from-tasty/a_from_tasty/.keep diff --git a/sbt-test/pipelining/Yjava-tasty-from-tasty/b-alt/.keep b/sbt-test/pipelining/Xjava-tasty-from-tasty/b-alt/.keep similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-from-tasty/b-alt/.keep rename to sbt-test/pipelining/Xjava-tasty-from-tasty/b-alt/.keep diff --git a/sbt-test/pipelining/Yjava-tasty-from-tasty/b/src/main/scala/b/B.scala b/sbt-test/pipelining/Xjava-tasty-from-tasty/b/src/main/scala/b/B.scala similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-from-tasty/b/src/main/scala/b/B.scala rename to sbt-test/pipelining/Xjava-tasty-from-tasty/b/src/main/scala/b/B.scala diff --git a/sbt-test/pipelining/Yjava-tasty-from-tasty/build.sbt b/sbt-test/pipelining/Xjava-tasty-from-tasty/build.sbt similarity index 87% rename from sbt-test/pipelining/Yjava-tasty-from-tasty/build.sbt rename to sbt-test/pipelining/Xjava-tasty-from-tasty/build.sbt index 040c3bf6eac8..3876ce28693d 100644 --- a/sbt-test/pipelining/Yjava-tasty-from-tasty/build.sbt +++ b/sbt-test/pipelining/Xjava-tasty-from-tasty/build.sbt @@ -2,22 +2,22 @@ lazy val a = project.in(file("a")) .settings( compileOrder := CompileOrder.Mixed, // ensure we send java sources to Scala compiler - scalacOptions += "-Yjava-tasty", // enable pickling of java signatures - scalacOptions ++= Seq("-Yearly-tasty-output", ((ThisBuild / baseDirectory).value / "a-pre-java-tasty.jar").toString), + scalacOptions += "-Xjava-tasty", // enable pickling of java signatures + scalacOptions ++= Seq("-Xearly-tasty-output", ((ThisBuild / baseDirectory).value / "a-pre-java-tasty.jar").toString), scalacOptions += "-Ycheck:all", Compile / classDirectory := ((ThisBuild / baseDirectory).value / "a-pre-classes"), // send classfiles to a different directory ) // recompile `a` with `-from-tasty` flag to test idempotent read/write java signatures. -// Requires -Yjava-tasty to be set in order to read them. +// Requires -Xjava-tasty to be set in order to read them. lazy val a_from_tasty = project.in(file("a_from_tasty")) .settings( Compile / sources := Seq((ThisBuild / baseDirectory).value / "a-pre-java-tasty.jar"), Compile / unmanagedClasspath := Seq(Attributed.blank((ThisBuild / baseDirectory).value / "a-pre-java-tasty.jar")), scalacOptions += "-from-tasty", // read the jar file tasties as the source files - scalacOptions += "-Yjava-tasty", - scalacOptions += "-Yallow-outline-from-tasty", // allow outline signatures to be read with -from-tasty - scalacOptions ++= Seq("-Yearly-tasty-output", ((ThisBuild / baseDirectory).value / "a_from_tasty-java-tasty.jar").toString), + scalacOptions += "-Xjava-tasty", + scalacOptions += "-Xallow-outline-from-tasty", // allow outline signatures to be read with -from-tasty + scalacOptions ++= Seq("-Xearly-tasty-output", ((ThisBuild / baseDirectory).value / "a_from_tasty-java-tasty.jar").toString), scalacOptions += "-Ycheck:all", Compile / classDirectory := ((ThisBuild / baseDirectory).value / "a_from_tasty-classes"), // send classfiles to a different directory ) diff --git a/sbt-test/pipelining/Yjava-tasty-from-tasty/project/DottyInjectedPlugin.scala b/sbt-test/pipelining/Xjava-tasty-from-tasty/project/DottyInjectedPlugin.scala similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-from-tasty/project/DottyInjectedPlugin.scala rename to sbt-test/pipelining/Xjava-tasty-from-tasty/project/DottyInjectedPlugin.scala diff --git a/sbt-test/pipelining/Yjava-tasty-from-tasty/test b/sbt-test/pipelining/Xjava-tasty-from-tasty/test similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-from-tasty/test rename to sbt-test/pipelining/Xjava-tasty-from-tasty/test diff --git a/sbt-test/pipelining/Yjava-tasty-fromjavaobject/a-check/.keep b/sbt-test/pipelining/Xjava-tasty-fromjavaobject/a-check/.keep similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-fromjavaobject/a-check/.keep rename to sbt-test/pipelining/Xjava-tasty-fromjavaobject/a-check/.keep diff --git a/sbt-test/pipelining/Yjava-tasty-fromjavaobject/a/src/main/scala/a/A.java b/sbt-test/pipelining/Xjava-tasty-fromjavaobject/a/src/main/scala/a/A.java similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-fromjavaobject/a/src/main/scala/a/A.java rename to sbt-test/pipelining/Xjava-tasty-fromjavaobject/a/src/main/scala/a/A.java diff --git a/sbt-test/pipelining/Yjava-tasty-fromjavaobject/a/src/main/scala/a/AImport.java b/sbt-test/pipelining/Xjava-tasty-fromjavaobject/a/src/main/scala/a/AImport.java similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-fromjavaobject/a/src/main/scala/a/AImport.java rename to sbt-test/pipelining/Xjava-tasty-fromjavaobject/a/src/main/scala/a/AImport.java diff --git a/sbt-test/pipelining/Yjava-tasty-fromjavaobject/a/src/main/scala/a/package.scala b/sbt-test/pipelining/Xjava-tasty-fromjavaobject/a/src/main/scala/a/package.scala similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-fromjavaobject/a/src/main/scala/a/package.scala rename to sbt-test/pipelining/Xjava-tasty-fromjavaobject/a/src/main/scala/a/package.scala diff --git a/sbt-test/pipelining/Yjava-tasty-fromjavaobject/b-alt/.keep b/sbt-test/pipelining/Xjava-tasty-fromjavaobject/b-alt/.keep similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-fromjavaobject/b-alt/.keep rename to sbt-test/pipelining/Xjava-tasty-fromjavaobject/b-alt/.keep diff --git a/sbt-test/pipelining/Yjava-tasty-fromjavaobject/b/src/main/scala/b/B.scala b/sbt-test/pipelining/Xjava-tasty-fromjavaobject/b/src/main/scala/b/B.scala similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-fromjavaobject/b/src/main/scala/b/B.scala rename to sbt-test/pipelining/Xjava-tasty-fromjavaobject/b/src/main/scala/b/B.scala diff --git a/sbt-test/pipelining/Yjava-tasty-fromjavaobject/b/src/main/scala/b/BImport.scala b/sbt-test/pipelining/Xjava-tasty-fromjavaobject/b/src/main/scala/b/BImport.scala similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-fromjavaobject/b/src/main/scala/b/BImport.scala rename to sbt-test/pipelining/Xjava-tasty-fromjavaobject/b/src/main/scala/b/BImport.scala diff --git a/sbt-test/pipelining/Yjava-tasty-fromjavaobject/build.sbt b/sbt-test/pipelining/Xjava-tasty-fromjavaobject/build.sbt similarity index 91% rename from sbt-test/pipelining/Yjava-tasty-fromjavaobject/build.sbt rename to sbt-test/pipelining/Xjava-tasty-fromjavaobject/build.sbt index 9013490f1f54..c51a266c2ee9 100644 --- a/sbt-test/pipelining/Yjava-tasty-fromjavaobject/build.sbt +++ b/sbt-test/pipelining/Xjava-tasty-fromjavaobject/build.sbt @@ -1,8 +1,8 @@ lazy val a = project.in(file("a")) .settings( compileOrder := CompileOrder.Mixed, // ensure we send java sources to Scala compiler - scalacOptions += "-Yjava-tasty", // enable pickling of java signatures - scalacOptions ++= Seq("-Yearly-tasty-output", ((ThisBuild / baseDirectory).value / "a-enum-java-tasty.jar").toString), + scalacOptions += "-Xjava-tasty", // enable pickling of java signatures + scalacOptions ++= Seq("-Xearly-tasty-output", ((ThisBuild / baseDirectory).value / "a-enum-java-tasty.jar").toString), scalacOptions += "-Ycheck:all", Compile / classDirectory := ((ThisBuild / baseDirectory).value / "a-enum-classes"), // send classfiles to a different directory ) @@ -13,8 +13,8 @@ lazy val aCheck = project.in(file("a-check")) scalacOptions += "-Ytest-pickler", // check that the pickler is correct Compile / sources := (a / Compile / sources).value, // use the same sources as a compileOrder := CompileOrder.Mixed, // ensure we send java sources to Scala compiler - scalacOptions += "-Yjava-tasty", // enable pickling of java signatures - scalacOptions ++= Seq("-Yearly-tasty-output", ((ThisBuild / baseDirectory).value / "a-enum-java-tasty-2.jar").toString), + scalacOptions += "-Xjava-tasty", // enable pickling of java signatures + scalacOptions ++= Seq("-Xearly-tasty-output", ((ThisBuild / baseDirectory).value / "a-enum-java-tasty-2.jar").toString), Compile / classDirectory := ((ThisBuild / baseDirectory).value / "a-enum-classes-2"), // send classfiles to a different directory ) diff --git a/sbt-test/pipelining/Yjava-tasty-fromjavaobject/c-alt/.keep b/sbt-test/pipelining/Xjava-tasty-fromjavaobject/c-alt/.keep similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-fromjavaobject/c-alt/.keep rename to sbt-test/pipelining/Xjava-tasty-fromjavaobject/c-alt/.keep diff --git a/sbt-test/pipelining/Yjava-tasty-fromjavaobject/c/src/main/scala/c/C.scala b/sbt-test/pipelining/Xjava-tasty-fromjavaobject/c/src/main/scala/c/C.scala similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-fromjavaobject/c/src/main/scala/c/C.scala rename to sbt-test/pipelining/Xjava-tasty-fromjavaobject/c/src/main/scala/c/C.scala diff --git a/sbt-test/pipelining/Yjava-tasty-fromjavaobject/c/src/main/scala/c/CImport.scala b/sbt-test/pipelining/Xjava-tasty-fromjavaobject/c/src/main/scala/c/CImport.scala similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-fromjavaobject/c/src/main/scala/c/CImport.scala rename to sbt-test/pipelining/Xjava-tasty-fromjavaobject/c/src/main/scala/c/CImport.scala diff --git a/sbt-test/pipelining/Yjava-tasty-fromjavaobject/project/DottyInjectedPlugin.scala b/sbt-test/pipelining/Xjava-tasty-fromjavaobject/project/DottyInjectedPlugin.scala similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-fromjavaobject/project/DottyInjectedPlugin.scala rename to sbt-test/pipelining/Xjava-tasty-fromjavaobject/project/DottyInjectedPlugin.scala diff --git a/sbt-test/pipelining/Yjava-tasty-fromjavaobject/test b/sbt-test/pipelining/Xjava-tasty-fromjavaobject/test similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-fromjavaobject/test rename to sbt-test/pipelining/Xjava-tasty-fromjavaobject/test diff --git a/sbt-test/pipelining/Yjava-tasty-generic/a/src/main/scala/a/A.java b/sbt-test/pipelining/Xjava-tasty-generic/a/src/main/scala/a/A.java similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-generic/a/src/main/scala/a/A.java rename to sbt-test/pipelining/Xjava-tasty-generic/a/src/main/scala/a/A.java diff --git a/sbt-test/pipelining/Yjava-tasty-generic/a/src/main/scala/a/package.scala b/sbt-test/pipelining/Xjava-tasty-generic/a/src/main/scala/a/package.scala similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-generic/a/src/main/scala/a/package.scala rename to sbt-test/pipelining/Xjava-tasty-generic/a/src/main/scala/a/package.scala diff --git a/sbt-test/pipelining/Yjava-tasty-generic/b-alt/.keep b/sbt-test/pipelining/Xjava-tasty-generic/b-alt/.keep similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-generic/b-alt/.keep rename to sbt-test/pipelining/Xjava-tasty-generic/b-alt/.keep diff --git a/sbt-test/pipelining/Yjava-tasty-generic/b/src/main/scala/b/B.scala b/sbt-test/pipelining/Xjava-tasty-generic/b/src/main/scala/b/B.scala similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-generic/b/src/main/scala/b/B.scala rename to sbt-test/pipelining/Xjava-tasty-generic/b/src/main/scala/b/B.scala diff --git a/sbt-test/pipelining/Yjava-tasty-generic/build.sbt b/sbt-test/pipelining/Xjava-tasty-generic/build.sbt similarity index 91% rename from sbt-test/pipelining/Yjava-tasty-generic/build.sbt rename to sbt-test/pipelining/Xjava-tasty-generic/build.sbt index 9e2796600333..c043d597c6cc 100644 --- a/sbt-test/pipelining/Yjava-tasty-generic/build.sbt +++ b/sbt-test/pipelining/Xjava-tasty-generic/build.sbt @@ -1,7 +1,7 @@ lazy val a = project.in(file("a")) .settings( - scalacOptions += "-Yjava-tasty", // enable pickling of java signatures - scalacOptions ++= Seq("-Yearly-tasty-output", ((ThisBuild / baseDirectory).value / "a-generic-java-tasty.jar").toString), + scalacOptions += "-Xjava-tasty", // enable pickling of java signatures + scalacOptions ++= Seq("-Xearly-tasty-output", ((ThisBuild / baseDirectory).value / "a-generic-java-tasty.jar").toString), scalacOptions += "-Ycheck:all", Compile / classDirectory := ((ThisBuild / baseDirectory).value / "a-generic-classes"), // send classfiles to a different directory ) diff --git a/sbt-test/pipelining/Yjava-tasty-generic/project/DottyInjectedPlugin.scala b/sbt-test/pipelining/Xjava-tasty-generic/project/DottyInjectedPlugin.scala similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-generic/project/DottyInjectedPlugin.scala rename to sbt-test/pipelining/Xjava-tasty-generic/project/DottyInjectedPlugin.scala diff --git a/sbt-test/pipelining/Yjava-tasty-generic/test b/sbt-test/pipelining/Xjava-tasty-generic/test similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-generic/test rename to sbt-test/pipelining/Xjava-tasty-generic/test diff --git a/sbt-test/pipelining/Yjava-tasty-paths/a/InnerClass.java b/sbt-test/pipelining/Xjava-tasty-paths/a/InnerClass.java similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-paths/a/InnerClass.java rename to sbt-test/pipelining/Xjava-tasty-paths/a/InnerClass.java diff --git a/sbt-test/pipelining/Yjava-tasty-paths/a/InnerClassGen.java b/sbt-test/pipelining/Xjava-tasty-paths/a/InnerClassGen.java similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-paths/a/InnerClassGen.java rename to sbt-test/pipelining/Xjava-tasty-paths/a/InnerClassGen.java diff --git a/sbt-test/pipelining/Yjava-tasty-paths/a/InnerClassSub.java b/sbt-test/pipelining/Xjava-tasty-paths/a/InnerClassSub.java similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-paths/a/InnerClassSub.java rename to sbt-test/pipelining/Xjava-tasty-paths/a/InnerClassSub.java diff --git a/sbt-test/pipelining/Yjava-tasty-paths/a/RawTypes.java b/sbt-test/pipelining/Xjava-tasty-paths/a/RawTypes.java similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-paths/a/RawTypes.java rename to sbt-test/pipelining/Xjava-tasty-paths/a/RawTypes.java diff --git a/sbt-test/pipelining/Yjava-tasty-paths/a/package.scala b/sbt-test/pipelining/Xjava-tasty-paths/a/package.scala similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-paths/a/package.scala rename to sbt-test/pipelining/Xjava-tasty-paths/a/package.scala diff --git a/sbt-test/pipelining/Yjava-tasty-paths/b/Test.scala b/sbt-test/pipelining/Xjava-tasty-paths/b/Test.scala similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-paths/b/Test.scala rename to sbt-test/pipelining/Xjava-tasty-paths/b/Test.scala diff --git a/sbt-test/pipelining/Yjava-tasty-paths/build.sbt b/sbt-test/pipelining/Xjava-tasty-paths/build.sbt similarity index 92% rename from sbt-test/pipelining/Yjava-tasty-paths/build.sbt rename to sbt-test/pipelining/Xjava-tasty-paths/build.sbt index 49487fccb57e..24a6f582647f 100644 --- a/sbt-test/pipelining/Yjava-tasty-paths/build.sbt +++ b/sbt-test/pipelining/Xjava-tasty-paths/build.sbt @@ -1,7 +1,7 @@ lazy val a = project.in(file("a")) .settings( - scalacOptions += "-Yjava-tasty", // enable pickling of java signatures - scalacOptions ++= Seq("-Yearly-tasty-output", ((ThisBuild / baseDirectory).value / "a-paths-java-tasty.jar").toString), + scalacOptions += "-Xjava-tasty", // enable pickling of java signatures + scalacOptions ++= Seq("-Xearly-tasty-output", ((ThisBuild / baseDirectory).value / "a-paths-java-tasty.jar").toString), scalacOptions += "-Ycheck:all", Compile / classDirectory := ((ThisBuild / baseDirectory).value / "a-paths-classes"), // send classfiles to a different directory ) diff --git a/sbt-test/pipelining/Yjava-tasty-paths/project/DottyInjectedPlugin.scala b/sbt-test/pipelining/Xjava-tasty-paths/project/DottyInjectedPlugin.scala similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-paths/project/DottyInjectedPlugin.scala rename to sbt-test/pipelining/Xjava-tasty-paths/project/DottyInjectedPlugin.scala diff --git a/sbt-test/pipelining/Yjava-tasty-paths/test b/sbt-test/pipelining/Xjava-tasty-paths/test similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-paths/test rename to sbt-test/pipelining/Xjava-tasty-paths/test diff --git a/sbt-test/pipelining/Yjava-tasty-result-types/a/src/main/scala/a/A.java b/sbt-test/pipelining/Xjava-tasty-result-types/a/src/main/scala/a/A.java similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-result-types/a/src/main/scala/a/A.java rename to sbt-test/pipelining/Xjava-tasty-result-types/a/src/main/scala/a/A.java diff --git a/sbt-test/pipelining/Yjava-tasty-result-types/a/src/main/scala/a/package.scala b/sbt-test/pipelining/Xjava-tasty-result-types/a/src/main/scala/a/package.scala similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-result-types/a/src/main/scala/a/package.scala rename to sbt-test/pipelining/Xjava-tasty-result-types/a/src/main/scala/a/package.scala diff --git a/sbt-test/pipelining/Yjava-tasty-result-types/b-alt/.keep b/sbt-test/pipelining/Xjava-tasty-result-types/b-alt/.keep similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-result-types/b-alt/.keep rename to sbt-test/pipelining/Xjava-tasty-result-types/b-alt/.keep diff --git a/sbt-test/pipelining/Yjava-tasty-result-types/b/src/main/scala/b/B.scala b/sbt-test/pipelining/Xjava-tasty-result-types/b/src/main/scala/b/B.scala similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-result-types/b/src/main/scala/b/B.scala rename to sbt-test/pipelining/Xjava-tasty-result-types/b/src/main/scala/b/B.scala diff --git a/sbt-test/pipelining/Yjava-tasty-result-types/build.sbt b/sbt-test/pipelining/Xjava-tasty-result-types/build.sbt similarity index 92% rename from sbt-test/pipelining/Yjava-tasty-result-types/build.sbt rename to sbt-test/pipelining/Xjava-tasty-result-types/build.sbt index 80bcf71b3365..f540de2d6599 100644 --- a/sbt-test/pipelining/Yjava-tasty-result-types/build.sbt +++ b/sbt-test/pipelining/Xjava-tasty-result-types/build.sbt @@ -1,7 +1,7 @@ lazy val a = project.in(file("a")) .settings( - scalacOptions += "-Yjava-tasty", // enable pickling of java signatures - scalacOptions ++= Seq("-Yearly-tasty-output", ((ThisBuild / baseDirectory).value / "a-result-types-java-tasty.jar").toString), + scalacOptions += "-Xjava-tasty", // enable pickling of java signatures + scalacOptions ++= Seq("-Xearly-tasty-output", ((ThisBuild / baseDirectory).value / "a-result-types-java-tasty.jar").toString), scalacOptions += "-Ycheck:all", Compile / classDirectory := ((ThisBuild / baseDirectory).value / "a-result-types-classes"), // send classfiles to a different directory ) diff --git a/sbt-test/pipelining/Yjava-tasty-result-types/project/DottyInjectedPlugin.scala b/sbt-test/pipelining/Xjava-tasty-result-types/project/DottyInjectedPlugin.scala similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-result-types/project/DottyInjectedPlugin.scala rename to sbt-test/pipelining/Xjava-tasty-result-types/project/DottyInjectedPlugin.scala diff --git a/sbt-test/pipelining/Yjava-tasty-result-types/test b/sbt-test/pipelining/Xjava-tasty-result-types/test similarity index 100% rename from sbt-test/pipelining/Yjava-tasty-result-types/test rename to sbt-test/pipelining/Xjava-tasty-result-types/test diff --git a/sbt-test/pipelining/pipelining-test/test b/sbt-test/pipelining/pipelining-test/test index e2b8e39082b2..1c996d6962e8 100644 --- a/sbt-test/pipelining/pipelining-test/test +++ b/sbt-test/pipelining/pipelining-test/test @@ -1,12 +1,12 @@ # run the tests on a project with pipelining -# exercises the fact that -Ypickle-java and -Ypickle-write +# exercises the fact that -Xjava-tasty and -Xpickle-write # flags are set twice. # steps: -# - Compile scope is compiled with flags `-Ypickle-java -Ypickle-write early/a-early-7423784.jar` +# - Compile scope is compiled with flags `-Xjava-tasty -Xpickle-write early/a-early-7423784.jar` # - sbt copies `early/a-early-7423784.jar` to `early/a-early.jar` -# - Test scope is compiled with flags `-Ypickle-java -Ypickle-write early-test/a-early-963232.jar -Ypickle-java -Ypickle-write early/a-early.jar -classpath early/a-early.jar` +# - Test scope is compiled with flags `-Xjava-tasty -Xpickle-write early-test/a-early-963232.jar -Xjava-tasty -Xpickle-write early/a-early.jar -classpath early/a-early.jar` # e.g. for some reason the classpath has the same `a-early.jar` that -# is passed with `Ypickle-write`. -# Therefore we MUST avoid even reading the second `-Ypickle-write` setting, +# is passed with `Xpickle-write`. +# Therefore we MUST avoid even reading the second `-Xpickle-write` setting, # otherwise we will zero-out `a-early.jar`, causing type errors because its contents are blank. > a/test diff --git a/tests/neg/i2887b.check b/tests/neg/i2887b.check index 7b85d1a0223b..5bd5f570fbf7 100644 --- a/tests/neg/i2887b.check +++ b/tests/neg/i2887b.check @@ -4,7 +4,7 @@ | Recursion limit exceeded. | Maybe there is an illegal cyclic reference? | If that's not the case, you could also try to increase the stacksize using the -Xss JVM option. - | For the unprocessed stack trace, compile with -Yno-decode-stacktraces. + | For the unprocessed stack trace, compile with -Xno-decode-stacktraces. | A recurring operation is (inner to outer): | | try to instantiate Z[Z] diff --git a/tests/neg/kind-projector-underscores.scala b/tests/neg/kind-projector-underscores.scala index 76aada871fae..e2cdee917e81 100644 --- a/tests/neg/kind-projector-underscores.scala +++ b/tests/neg/kind-projector-underscores.scala @@ -1,4 +1,4 @@ -//> using options -Ykind-projector:underscores +//> using options -Xkind-projector:underscores package kind_projector_neg diff --git a/tests/neg/kind-projector.scala b/tests/neg/kind-projector.scala index a7fc24c70b93..a03dd83a1945 100644 --- a/tests/neg/kind-projector.scala +++ b/tests/neg/kind-projector.scala @@ -1,4 +1,4 @@ -//> using options -Ykind-projector +//> using options -Xkind-projector package kind_projector_neg diff --git a/tests/pos/i16777.scala b/tests/pos/i16777.scala index 302ace3ea9aa..4b7399ac053c 100644 --- a/tests/pos/i16777.scala +++ b/tests/pos/i16777.scala @@ -1,4 +1,4 @@ -//> using options -Ykind-projector:underscores +//> using options -Xkind-projector:underscores sealed abstract class Free[+S[_, _], +E, +A] { @inline final def flatMap[S1[e, a] >: S[e, a], B, E1 >: E](fun: A => Free[S1, E1, B]): Free[S1, E1, B] = Free.FlatMapped[S1, E, E1, A, B](this, fun) diff --git a/tests/pos/i19806/Module.scala b/tests/pos/i19806/Module.scala index d0142fc24682..328dcd213d2e 100644 --- a/tests/pos/i19806/Module.scala +++ b/tests/pos/i19806/Module.scala @@ -1,4 +1,4 @@ -//> using options -Yjava-tasty -Ytest-pickler-check +//> using options -Xjava-tasty -Ytest-pickler-check package p diff --git a/tests/pos/kind-projector-underscores.scala b/tests/pos/kind-projector-underscores.scala index f72a300a64eb..6f4349a8ec7c 100644 --- a/tests/pos/kind-projector-underscores.scala +++ b/tests/pos/kind-projector-underscores.scala @@ -1,4 +1,4 @@ -//> using options -Ykind-projector:underscores +//> using options -Xkind-projector:underscores package kind_projector diff --git a/tests/pos/kind-projector.scala b/tests/pos/kind-projector.scala index 4d6ec8c932a9..7e4a2c7f5c1b 100644 --- a/tests/pos/kind-projector.scala +++ b/tests/pos/kind-projector.scala @@ -1,4 +1,4 @@ -//> using options -Ykind-projector +//> using options -Xkind-projector package kind_projector diff --git a/tests/run-macros/i12351/Test_2.scala b/tests/run-macros/i12351/Test_2.scala index e480b3c7e86e..a48d30772d5c 100644 --- a/tests/run-macros/i12351/Test_2.scala +++ b/tests/run-macros/i12351/Test_2.scala @@ -1,4 +1,4 @@ -//> using options -Yread-docs +//> using options -Xread-docs @main def Test(): Unit = { println(getDocString[Data]) diff --git a/tests/run-macros/i12352/Main.scala b/tests/run-macros/i12352/Main.scala index b62bd80eaf2c..19cdf2a82d3b 100644 --- a/tests/run-macros/i12352/Main.scala +++ b/tests/run-macros/i12352/Main.scala @@ -1,4 +1,4 @@ -//> using options -Yread-docs +//> using options -Xread-docs @main def Test(): Unit = { val res = getDocString[scala.quoted.Quotes] diff --git a/tests/untried/neg/choices.check b/tests/untried/neg/choices.check index b114394e9609..2e45461ca178 100644 --- a/tests/untried/neg/choices.check +++ b/tests/untried/neg/choices.check @@ -1,2 +1,2 @@ -error: bad options: -Yresolve-term-conflict +error: bad options: -Xresolve-term-conflict one error found diff --git a/tests/untried/neg/choices.flags b/tests/untried/neg/choices.flags index 9718467d4ca2..7a04890a6dee 100644 --- a/tests/untried/neg/choices.flags +++ b/tests/untried/neg/choices.flags @@ -1 +1 @@ --Yresolve-term-conflict +-Xresolve-term-conflict From c6af824869405c889dbf8bf8f2afa1c4ee19d554 Mon Sep 17 00:00:00 2001 From: rochala Date: Tue, 16 Apr 2024 13:43:53 +0200 Subject: [PATCH 02/19] Lift -Ysafe-init to -Wsafe-init --- Test.scala | 1 - .../scala/dotty/communitybuild/projects.scala | 18 +++++++++--------- .../tools/dotc/config/ScalaSettings.scala | 11 ++++++++++- .../src/dotty/tools/dotc/core/Symbols.scala | 2 +- .../tools/dotc/transform/init/Checker.scala | 4 ++-- .../dotty/tools/dotc/CompilationTests.scala | 18 +++++++++--------- .../tools/dotc/config/ScalaSettingsTests.scala | 2 ++ .../reference/experimental/explicit-nulls.md | 2 +- .../other-new-features/safe-initialization.md | 2 +- .../other-new-features/safe-initialization.md | 2 +- project/Build.scala | 16 ++++++++++++---- tests/explicit-nulls/pos/i14682.scala | 4 ++-- tests/neg/i16438.scala | 2 +- 13 files changed, 51 insertions(+), 33 deletions(-) delete mode 100644 Test.scala diff --git a/Test.scala b/Test.scala deleted file mode 100644 index 5486d1260b41..000000000000 --- a/Test.scala +++ /dev/null @@ -1 +0,0 @@ -@main def hello = println("Hello, world!") diff --git a/community-build/src/scala/dotty/communitybuild/projects.scala b/community-build/src/scala/dotty/communitybuild/projects.scala index cc0f0ac1f20f..a5797cda0a77 100644 --- a/community-build/src/scala/dotty/communitybuild/projects.scala +++ b/community-build/src/scala/dotty/communitybuild/projects.scala @@ -149,7 +149,7 @@ final case class SbtCommunityProject( object SbtCommunityProject: def scalacOptions = List( "-Xcheck-macros", - "-Ysafe-init", + "-Wsafe-init", ) object projects: @@ -362,7 +362,7 @@ object projects: project = "shapeless-3", sbtTestCommand = "testJVM; testJS", sbtDocCommand = forceDoc("typeable", "deriving"), - scalacOptions = "-source" :: "3.3" :: SbtCommunityProject.scalacOptions.filter(_ != "-Ysafe-init"), // due to -Xfatal-warnings + scalacOptions = "-source" :: "3.3" :: SbtCommunityProject.scalacOptions.filter(!List("-Ysafe-init", "-Wsafe-init").contains), // due to -Xfatal-warnings ) lazy val xmlInterpolator = SbtCommunityProject( @@ -429,7 +429,7 @@ object projects: sbtTestCommand = "unitTests/test", // Adds package sbtDocCommand = "coreJVM/doc", - scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Ysafe-init"), + scalacOptions = SbtCommunityProject.scalacOptions.filter(!List("-Ysafe-init", "-Wsafe-init").contains), dependencies = List(munit, scodecBits), ) @@ -510,7 +510,7 @@ object projects: project = "discipline", sbtTestCommand = "coreJVM/test;coreJS/test", sbtPublishCommand = "set every credentials := Nil;coreJVM/publishLocal;coreJS/publishLocal", - scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Ysafe-init"), + scalacOptions = SbtCommunityProject.scalacOptions.filter(!List("-Ysafe-init", "-Wsafe-init").contains), dependencies = List(scalacheck) ) @@ -526,7 +526,7 @@ object projects: sbtTestCommand = "test", sbtPublishCommand = "coreJVM/publishLocal;coreJS/publishLocal", dependencies = List(discipline), - scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Ysafe-init") + scalacOptions = SbtCommunityProject.scalacOptions.filter(!List("-Ysafe-init", "-Wsafe-init").contains) ) lazy val simulacrumScalafixAnnotations = SbtCommunityProject( @@ -540,7 +540,7 @@ object projects: sbtTestCommand = "set Global/scalaJSStage := FastOptStage;rootJVM/test;rootJS/test", sbtPublishCommand = "rootJVM/publishLocal;rootJS/publishLocal", dependencies = List(discipline, disciplineMunit, scalacheck, simulacrumScalafixAnnotations), - scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Ysafe-init") // disable -Ysafe-init, due to -Xfatal-warning + scalacOptions = SbtCommunityProject.scalacOptions.filter(!List("-Ysafe-init", "-Wsafe-init").contains) // disable -Ysafe-init or -Wsafe-init, due to -Xfatal-warning ) @@ -656,7 +656,7 @@ object projects: """set actorTests/Compile/scalacOptions -= "-Xfatal-warnings"""", "akka-actor-tests/Test/compile", ).mkString("; "), - scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Ysafe-init"), + scalacOptions = SbtCommunityProject.scalacOptions.filter(!List("-Ysafe-init", "-Wsafe-init").contains), dependencies = List(scalatest, scalatestplusJunit, scalatestplusScalacheck) ) @@ -707,7 +707,7 @@ object projects: project = "fs2", sbtTestCommand = "coreJVM/test; coreJS/test", // io/test requires JDK9+ sbtPublishCommand = "coreJVM/publishLocal; coreJS/publishLocal", - scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Ysafe-init"), + scalacOptions = SbtCommunityProject.scalacOptions.filter(!List("-Ysafe-init", "-Wsafe-init").contains), dependencies = List(cats, catsEffect3, munitCatsEffect, scalacheckEffect, scodecBits) ) @@ -744,7 +744,7 @@ object projects: project = "http4s", sbtTestCommand = """set ThisBuild / tlFatalWarnings := false; rootJVM/test""", sbtPublishCommand = "publishLocal", - scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Ysafe-init"), + scalacOptions = SbtCommunityProject.scalacOptions.filter(!List("-Ysafe-init", "-Wsafe-init").contains), dependencies = List(cats, catsEffect3, fs2, disciplineMunit, scalacheckEffect) ) diff --git a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala index 66be2b3c7317..35358dc03df6 100644 --- a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala +++ b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala @@ -296,6 +296,7 @@ private sealed trait WarningSettings: def typeParameterShadow(using Context) = allOr("type-parameter-shadow") + val WcheckInit: Setting[Boolean] = BooleanSetting(WarningSetting, "Wsafe-init", "Ensure safe initialization of objects.") /** -X "Extended" or "Advanced" settings */ private sealed trait XSettings: @@ -327,12 +328,18 @@ private sealed trait XSettings: val Xdumpclasses: Setting[String] = StringSetting(AdvancedSetting, "Xdump-classes", "dir", "Dump the generated bytecode to .class files (useful for reflective compilation that utilizes in-memory classloaders).", "") val XjarCompressionLevel: Setting[Int] = IntChoiceSetting(AdvancedSetting, "Xjar-compression-level", "compression level to use when writing jar files", Deflater.DEFAULT_COMPRESSION to Deflater.BEST_COMPRESSION, Deflater.DEFAULT_COMPRESSION) val XkindProjector: Setting[String] = ChoiceSetting(AdvancedSetting, "Xkind-projector", "[underscores, enable, disable]", "Allow `*` as type lambda placeholder to be compatible with kind projector. When invoked as -Xkind-projector:underscores will repurpose `_` to be a type parameter placeholder, this will disable usage of underscore as a wildcard.", List("disable", "", "underscores"), "disable", legacyArgs = true) + + /** Documentation related settings */ val XdropComments: Setting[Boolean] = BooleanSetting(AdvancedSetting, "Xdrop-docs", "Drop documentation when scanning source files.", aliases = List("-Xdrop-comments")) val XcookComments: Setting[Boolean] = BooleanSetting(AdvancedSetting, "Xcook-docs", "Cook the documentation (type check `@usecase`, etc.)", aliases = List("-Xcook-comments")) val XreadComments: Setting[Boolean] = BooleanSetting(AdvancedSetting, "Xread-docs", "Read documentation from tasty.") + + /** Area-specific debug output */ val XnoDecodeStacktraces: Setting[Boolean] = BooleanSetting(AdvancedSetting, "Xno-decode-stacktraces", "Show raw StackOverflow stacktraces, instead of decoding them into triggering operations.") val XnoEnrichErrorMessages: Setting[Boolean] = BooleanSetting(AdvancedSetting, "Xno-enrich-error-messages", "Show raw error messages, instead of enriching them with contextual information.") val XdebugMacros: Setting[Boolean] = BooleanSetting(AdvancedSetting, "Xdebug-macros", "Show debug info when quote pattern match fails") + + /** Pipeline compilation options */ val XjavaTasty: Setting[Boolean] = BooleanSetting(AdvancedSetting, "Xjava-tasty", "Pickler phase should compute TASTy for .java defined symbols for use by build tools", aliases = List("-Xpickle-java"), preferPrevious = true) val XearlyTastyOutput: Setting[AbstractFile] = OutputSetting(AdvancedSetting, "Xearly-tasty-output", "directory|jar", "Destination to write generated .tasty files to for use in pipelined compilation.", NoAbstractFile, aliases = List("-Xpickle-write"), preferPrevious = true) val XallowOutlineFromTasty: Setting[Boolean] = BooleanSetting(AdvancedSetting, "Xallow-outline-from-tasty", "Allow outline TASTy to be loaded with the -from-tasty option.") @@ -443,7 +450,6 @@ private sealed trait YSettings: val YnoKindPolymorphism: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-kind-polymorphism", "Disable kind polymorphism.") val YexplicitNulls: Setting[Boolean] = BooleanSetting(ForkSetting, "Yexplicit-nulls", "Make reference types non-nullable. Nullable types can be expressed with unions: e.g. String|Null.") val YnoFlexibleTypes: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-flexible-types", "Disable turning nullable Java return types and parameter types into flexible types, which behave like abstract types with a nullable lower bound and non-nullable upper bound.") - val YcheckInit: Setting[Boolean] = BooleanSetting(ForkSetting, "Ysafe-init", "Ensure safe initialization of objects.") val YcheckInitGlobal: Setting[Boolean] = BooleanSetting(ForkSetting, "Ysafe-init-global", "Check safe initialization of global objects.") val YrequireTargetName: Setting[Boolean] = BooleanSetting(ForkSetting, "Yrequire-targetName", "Warn if an operator is defined without a @targetName annotation.") val YrecheckTest: Setting[Boolean] = BooleanSetting(ForkSetting, "Yrecheck-test", "Run basic rechecking (internal test only).") @@ -475,4 +481,7 @@ private sealed trait YSettings: val YjavaTasty: Setting[Boolean] = BooleanSetting(ForkSetting, "Yjava-tasty", "Pickler phase should compute TASTy for .java defined symbols for use by build tools", aliases = List("-Ypickle-java"), preferPrevious = true, deprecation = Some(Deprecation("Use -Xjava-tasty instead.", "-Xjava-tasty"))) val YearlyTastyOutput: Setting[AbstractFile] = OutputSetting(ForkSetting, "Yearly-tasty-output", "directory|jar", "Destination to write generated .tasty files to for use in pipelined compilation.", NoAbstractFile, aliases = List("-Ypickle-write"), preferPrevious = true, deprecation = Some(Deprecation("Use -Xearly-tasty-output instead.", "-Xearly-tasty-output"))) val YallowOutlineFromTasty: Setting[Boolean] = BooleanSetting(ForkSetting, "Yallow-outline-from-tasty", "Allow outline TASTy to be loaded with the -from-tasty option.", deprecation = Some(Deprecation("Use -Xallow-outline-from-tasty instead.", "-Xallow-outline-from-tasty"))) + + // Deprecated: lifted from -Y to -W + val YcheckInit: Setting[Boolean] = BooleanSetting(ForkSetting, "Ysafe-init", "Ensure safe initialization of objects.", deprecation = Some(Deprecation("Use -Wsafe-init instead.", "-Wsafe-init"))) end YSettings diff --git a/compiler/src/dotty/tools/dotc/core/Symbols.scala b/compiler/src/dotty/tools/dotc/core/Symbols.scala index 7f6f13585efd..0020efa5018d 100644 --- a/compiler/src/dotty/tools/dotc/core/Symbols.scala +++ b/compiler/src/dotty/tools/dotc/core/Symbols.scala @@ -84,7 +84,7 @@ object Symbols extends SymUtils { ctx.settings.YretainTrees.value || denot.owner.isTerm || // no risk of leaking memory after a run for these denot.isOneOf(InlineOrProxy) || // need to keep inline info - ctx.settings.YcheckInit.value || // initialization check + ctx.settings.WcheckInit.value || // initialization check ctx.settings.YcheckInitGlobal.value /** The last denotation of this symbol */ diff --git a/compiler/src/dotty/tools/dotc/transform/init/Checker.scala b/compiler/src/dotty/tools/dotc/transform/init/Checker.scala index 1a4141f3d495..9e78bd5474a3 100644 --- a/compiler/src/dotty/tools/dotc/transform/init/Checker.scala +++ b/compiler/src/dotty/tools/dotc/transform/init/Checker.scala @@ -29,7 +29,7 @@ class Checker extends Phase: override val runsAfter = Set(Pickler.name) override def isEnabled(using Context): Boolean = - super.isEnabled && (ctx.settings.YcheckInit.value || ctx.settings.YcheckInitGlobal.value) + super.isEnabled && (ctx.settings.WcheckInit.value || ctx.settings.YcheckInitGlobal.value) def traverse(traverser: InitTreeTraverser)(using Context): Boolean = monitor(phaseName): val unit = ctx.compilationUnit @@ -50,7 +50,7 @@ class Checker extends Phase: cancellable { val classes = traverser.getClasses() - if ctx.settings.YcheckInit.value then + if ctx.settings.WcheckInit.value then Semantic.checkClasses(classes)(using checkCtx) if ctx.settings.YcheckInitGlobal.value then diff --git a/compiler/test/dotty/tools/dotc/CompilationTests.scala b/compiler/test/dotty/tools/dotc/CompilationTests.scala index 2084b11d0b97..de3bd02bba6e 100644 --- a/compiler/test/dotty/tools/dotc/CompilationTests.scala +++ b/compiler/test/dotty/tools/dotc/CompilationTests.scala @@ -31,8 +31,8 @@ class CompilationTests { @Test def pos: Unit = { implicit val testGroup: TestGroup = TestGroup("compilePos") var tests = List( - compileFilesInDir("tests/pos", defaultOptions.and("-Ysafe-init", "-Wunused:all", "-Wshadow:private-shadow", "-Wshadow:type-parameter-shadow"), FileFilter.include(TestSources.posLintingAllowlist)), - compileFilesInDir("tests/pos", defaultOptions.and("-Ysafe-init"), FileFilter.exclude(TestSources.posLintingAllowlist)), + compileFilesInDir("tests/pos", defaultOptions.and("-Wsafe-init", "-Wunused:all", "-Wshadow:private-shadow", "-Wshadow:type-parameter-shadow"), FileFilter.include(TestSources.posLintingAllowlist)), + compileFilesInDir("tests/pos", defaultOptions.and("-Wsafe-init"), FileFilter.exclude(TestSources.posLintingAllowlist)), compileFilesInDir("tests/pos-deep-subtype", allowDeepSubtypes), compileFilesInDir("tests/pos-special/sourcepath/outer", defaultOptions.and("-sourcepath", "tests/pos-special/sourcepath")), compileFile("tests/pos-special/sourcepath/outer/nested/Test4.scala", defaultOptions.and("-sourcepath", "tests/pos-special/sourcepath")), @@ -40,9 +40,9 @@ class CompilationTests { compileFilesInDir("tests/pos-custom-args/captures", defaultOptions.and("-language:experimental.captureChecking")), compileFile("tests/pos-special/utf8encoded.scala", defaultOptions.and("-encoding", "UTF8")), compileFile("tests/pos-special/utf16encoded.scala", defaultOptions.and("-encoding", "UTF16")), - compileDir("tests/pos-special/i18589", defaultOptions.and("-Ysafe-init").without("-Ycheck:all")), + compileDir("tests/pos-special/i18589", defaultOptions.and("-Wsafe-init").without("-Ycheck:all")), // Run tests for legacy lazy vals - compileFilesInDir("tests/pos", defaultOptions.and("-Ysafe-init", "-Ylegacy-lazy-vals", "-Ycheck-constraint-deps"), FileFilter.include(TestSources.posLazyValsAllowlist)), + compileFilesInDir("tests/pos", defaultOptions.and("-Wsafe-init", "-Ylegacy-lazy-vals", "-Ycheck-constraint-deps"), FileFilter.include(TestSources.posLazyValsAllowlist)), compileDir("tests/pos-special/java-param-names", defaultOptions.withJavacOnlyOptions("-parameters")), ) ::: ( // TODO create a folder for capture checking tests with the stdlib, or use tests/pos-custom-args/captures under this mode? @@ -51,7 +51,7 @@ class CompilationTests { ) if scala.util.Properties.isJavaAtLeast("16") then - tests ::= compileFilesInDir("tests/pos-java16+", defaultOptions.and("-Ysafe-init")) + tests ::= compileFilesInDir("tests/pos-java16+", defaultOptions.and("-Wsafe-init")) aggregateTests(tests*).checkCompile() } @@ -157,11 +157,11 @@ class CompilationTests { @Test def runAll: Unit = { implicit val testGroup: TestGroup = TestGroup("runAll") aggregateTests( - compileFilesInDir("tests/run", defaultOptions.and("-Ysafe-init")), + compileFilesInDir("tests/run", defaultOptions.and("-Wsafe-init")), compileFilesInDir("tests/run-deep-subtype", allowDeepSubtypes), compileFilesInDir("tests/run-custom-args/captures", allowDeepSubtypes.and("-language:experimental.captureChecking")), // Run tests for legacy lazy vals. - compileFilesInDir("tests/run", defaultOptions.and("-Ysafe-init", "-Ylegacy-lazy-vals", "-Ycheck-constraint-deps"), FileFilter.include(TestSources.runLazyValsAllowlist)), + compileFilesInDir("tests/run", defaultOptions.and("-Wsafe-init", "-Ylegacy-lazy-vals", "-Ycheck-constraint-deps"), FileFilter.include(TestSources.runLazyValsAllowlist)), ).checkRuns() } @@ -225,9 +225,9 @@ class CompilationTests { // initialization tests @Test def checkInit: Unit = { implicit val testGroup: TestGroup = TestGroup("checkInit") - val options = defaultOptions.and("-Ysafe-init", "-Xfatal-warnings") + val options = defaultOptions.and("-Wsafe-init", "-Xfatal-warnings") compileFilesInDir("tests/init/neg", options).checkExpectedErrors() - compileFilesInDir("tests/init/warn", defaultOptions.and("-Ysafe-init")).checkWarnings() + compileFilesInDir("tests/init/warn", defaultOptions.and("-Wsafe-init")).checkWarnings() compileFilesInDir("tests/init/pos", options).checkCompile() compileFilesInDir("tests/init/crash", options.without("-Xfatal-warnings")).checkCompile() // The regression test for i12128 has some atypical classpath requirements. diff --git a/compiler/test/dotty/tools/dotc/config/ScalaSettingsTests.scala b/compiler/test/dotty/tools/dotc/config/ScalaSettingsTests.scala index 3c0b165b6457..e739c60a8f53 100644 --- a/compiler/test/dotty/tools/dotc/config/ScalaSettingsTests.scala +++ b/compiler/test/dotty/tools/dotc/config/ScalaSettingsTests.scala @@ -108,6 +108,7 @@ class ScalaSettingsTests: createTestCase(settings.YjavaTasty , settings.XjavaTasty), createTestCase(settings.YearlyTastyOutput , settings.XearlyTastyOutput, ":./"), createTestCase(settings.YallowOutlineFromTasty, settings.XallowOutlineFromTasty), + createTestCase(settings.YcheckInit , settings.WcheckInit), ).map: (deprecatedArgument, newSetting) => val args = List(deprecatedArgument) val argSummary = ArgsSummary(settings.defaultState, args, errors = Nil, warnings = Nil) @@ -135,6 +136,7 @@ class ScalaSettingsTests: createTestCase(settings.YjavaTasty , settings.XjavaTasty), createTestCase(settings.YearlyTastyOutput , settings.XearlyTastyOutput, ":./"), createTestCase(settings.YallowOutlineFromTasty, settings.XallowOutlineFromTasty), + createTestCase(settings.YcheckInit , settings.WcheckInit), ).flatten.map: (deprecatedArgument, newSetting) => val args = List(deprecatedArgument) val argSummary = ArgsSummary(settings.defaultState, args, errors = Nil, warnings = Nil) diff --git a/docs/_docs/reference/experimental/explicit-nulls.md b/docs/_docs/reference/experimental/explicit-nulls.md index bcbea34dd18d..50339c3fa1e4 100644 --- a/docs/_docs/reference/experimental/explicit-nulls.md +++ b/docs/_docs/reference/experimental/explicit-nulls.md @@ -85,7 +85,7 @@ val c = new C() // c.f == "field is null" ``` -The unsoundness above can be caught by the compiler with the option `-Ysafe-init`. +The unsoundness above can be caught by the compiler with the option `-Wsafe-init`. More details can be found in [safe initialization](../other-new-features/safe-initialization.md). ## Equality diff --git a/docs/_docs/reference/other-new-features/safe-initialization.md b/docs/_docs/reference/other-new-features/safe-initialization.md index 757038eac786..503dbc7bde47 100644 --- a/docs/_docs/reference/other-new-features/safe-initialization.md +++ b/docs/_docs/reference/other-new-features/safe-initialization.md @@ -4,7 +4,7 @@ title: "Safe Initialization" nightlyOf: https://docs.scala-lang.org/scala3/reference/other-new-features/safe-initialization.html --- -Scala 3 implements experimental safe initialization check, which can be enabled by the compiler option `-Ysafe-init`. +Scala 3 implements experimental safe initialization check, which can be enabled by the compiler option `-Wsafe-init`. The design and implementation of the initialization checker is described in the paper _Safe object initialization, abstractly_ [3]. diff --git a/docs/_spec/TODOreference/other-new-features/safe-initialization.md b/docs/_spec/TODOreference/other-new-features/safe-initialization.md index 757038eac786..503dbc7bde47 100644 --- a/docs/_spec/TODOreference/other-new-features/safe-initialization.md +++ b/docs/_spec/TODOreference/other-new-features/safe-initialization.md @@ -4,7 +4,7 @@ title: "Safe Initialization" nightlyOf: https://docs.scala-lang.org/scala3/reference/other-new-features/safe-initialization.html --- -Scala 3 implements experimental safe initialization check, which can be enabled by the compiler option `-Ysafe-init`. +Scala 3 implements experimental safe initialization check, which can be enabled by the compiler option `-Wsafe-init`. The design and implementation of the initialization checker is described in the paper _Safe object initialization, abstractly_ [3]. diff --git a/project/Build.scala b/project/Build.scala index aaa16ce4bce4..350471cc3e12 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -602,8 +602,8 @@ object Build { // Settings shared between scala3-compiler and scala3-compiler-bootstrapped lazy val commonDottyCompilerSettings = Seq( - // Note: bench/profiles/projects.yml should be updated accordingly. - Compile / scalacOptions ++= Seq("-Yexplicit-nulls", "-Ysafe-init"), + // Note: bench/profiles/projects.yml should be updated accordingly. + Compile / scalacOptions ++= Seq("-Yexplicit-nulls"), // Use source 3.3 to avoid fatal migration warnings on scalajs-ir scalacOptions ++= Seq("-source", "3.3"), @@ -880,6 +880,8 @@ object Build { } lazy val nonBootstrappedDottyCompilerSettings = commonDottyCompilerSettings ++ Seq( + // FIXME revert this to commonDottyCompilerSettings, when we bump reference version to 3.5.0 + scalacOptions += "-Ysafe-init", // packageAll packages all and then returns a map with the abs location packageAll := Def.taskDyn { // Use a dynamic task to avoid loops when loading the settings Def.task { @@ -907,6 +909,8 @@ object Build { ) lazy val bootstrappedDottyCompilerSettings = commonDottyCompilerSettings ++ Seq( + // FIXME revert this to commonDottyCompilerSettings, when we bump reference version to 3.5.0 + scalacOptions += "-Wsafe-init", javaOptions ++= { val jars = packageAll.value Seq( @@ -1334,7 +1338,7 @@ object Build { BuildInfoPlugin.buildInfoScopedSettings(Test) ++ BuildInfoPlugin.buildInfoDefaultSettings - lazy val presentationCompilerSettings = { + def presentationCompilerSettings(implicit mode: Mode) = { val mtagsVersion = "1.3.0+56-a06a024d-SNAPSHOT" Seq( @@ -1348,7 +1352,11 @@ object Build { ivyConfigurations += SourceDeps.hide, transitiveClassifiers := Seq("sources"), scalacOptions ++= Seq("-source", "3.3"), // To avoid fatal migration warnings - Compile / scalacOptions ++= Seq("-Yexplicit-nulls", "-Ysafe-init"), + // FIXME change this to just Seq("-Yexplicit-nulls, "-Wsafe-init") when reference is set to 3.5.0 + Compile / scalacOptions ++= (mode match { + case Bootstrapped => Seq("-Yexplicit-nulls", "-Wsafe-init") + case NonBootstrapped => Seq("-Yexplicit-nulls", "-Ysafe-init") + }), Compile / sourceGenerators += Def.task { val s = streams.value val cacheDir = s.cacheDirectory diff --git a/tests/explicit-nulls/pos/i14682.scala b/tests/explicit-nulls/pos/i14682.scala index 318de6094a88..76ae621a406e 100644 --- a/tests/explicit-nulls/pos/i14682.scala +++ b/tests/explicit-nulls/pos/i14682.scala @@ -1,4 +1,4 @@ -//> using options -Ysafe-init +//> using options -Wsafe-init class C1: sealed abstract class Name { @@ -26,4 +26,4 @@ class C2: val localName = LocalName() println(localName) - var count = 0 \ No newline at end of file + var count = 0 diff --git a/tests/neg/i16438.scala b/tests/neg/i16438.scala index a2b88080c2cd..793e6518ea71 100644 --- a/tests/neg/i16438.scala +++ b/tests/neg/i16438.scala @@ -1,4 +1,4 @@ -//> using options -Ysafe-init +//> using options -Wsafe-init trait ATrait(val string: String, val int: Int) trait AnotherTrait( override val string: String, override val int: Int) extends ATrait case class ACaseClass(override val string: String) extends AnotherTrait(string, 3) // error From 212677256cb957a9014e0856658c96abb8e76ec2 Mon Sep 17 00:00:00 2001 From: rochala Date: Tue, 16 Apr 2024 14:20:05 +0200 Subject: [PATCH 03/19] Add deprecation message to -{Y, X, W, ...} compiler flag --- compiler/src/dotty/tools/dotc/config/CliCommand.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/config/CliCommand.scala b/compiler/src/dotty/tools/dotc/config/CliCommand.scala index be97297218fa..5ac6b772df95 100644 --- a/compiler/src/dotty/tools/dotc/config/CliCommand.scala +++ b/compiler/src/dotty/tools/dotc/config/CliCommand.scala @@ -60,7 +60,8 @@ trait CliCommand: def defaultValue = s.default match case _: Int | _: String => s.default.toString case _ => "" - val info = List(shortHelp(s), if defaultValue.nonEmpty then s"Default $defaultValue" else "", if s.legalChoices.nonEmpty then s"Choices : ${s.legalChoices}" else "") + val deprecationMessage = s.deprecation.map(d => s"Option deprecated.\n${d.msg}").getOrElse("") + val info = List(deprecationMessage, shortHelp(s), if defaultValue.nonEmpty then s"Default $defaultValue" else "", if s.legalChoices.nonEmpty then s"Choices : ${s.legalChoices}" else "") (s.name, info.filter(_.nonEmpty).mkString("\n")) end help From 60dc3fd8df1cbfafaabb3b7b7d4d27cd7a4add8d Mon Sep 17 00:00:00 2001 From: rochala Date: Tue, 16 Apr 2024 15:03:29 +0200 Subject: [PATCH 04/19] Update all references to new settings --- .../dotty/tools/dotc/core/tasty/CommentPicklingTest.scala | 2 +- docs/_docs/reference/changed-features/wildcards.md | 6 +++--- docs/_spec/APPLIEDreference/changed-features/wildcards.md | 6 +++--- .../src/dotty/tools/scaladoc/snippets/SnippetCompiler.scala | 4 ++-- scaladoc/src/scala/tasty/inspector/TastyInspector.scala | 2 +- .../src/scala/tasty/inspector/TastyInspector.scala | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/compiler/test/dotty/tools/dotc/core/tasty/CommentPicklingTest.scala b/compiler/test/dotty/tools/dotc/core/tasty/CommentPicklingTest.scala index 11406070ce7a..072944da1349 100644 --- a/compiler/test/dotty/tools/dotc/core/tasty/CommentPicklingTest.scala +++ b/compiler/test/dotty/tools/dotc/core/tasty/CommentPicklingTest.scala @@ -110,7 +110,7 @@ class CommentPicklingTest { private class UnpicklingDriver extends Driver { override def initCtx = val ctx = super.initCtx.fresh - ctx.setSetting(ctx.settings.YreadComments, true) + ctx.setSetting(ctx.settings.XreadComments, true) ctx def unpickle[T](args: Array[String], files: List[File])(fn: (List[tpd.Tree], Context) => T): T = { diff --git a/docs/_docs/reference/changed-features/wildcards.md b/docs/_docs/reference/changed-features/wildcards.md index 3ed7e01cb535..ac7235770e36 100644 --- a/docs/_docs/reference/changed-features/wildcards.md +++ b/docs/_docs/reference/changed-features/wildcards.md @@ -35,16 +35,16 @@ A step-by-step migration is made possible with the following measures: 4. Some deprecation warnings are already available under the `-source future` setting. To smooth the transition for codebases that use kind-projector, we adopt the following measures under the command line -option `-Xkind-projector`: +option `-Ykind-projector`: 1. In Scala 3.0, `*` is available as a type parameter placeholder. 2. In Scala 3.2, `*` is deprecated in favor of `_`. A `-rewrite` option is available to rewrite one to the other. 3. In Scala 3.3, `*` is removed again, and all type parameter placeholders will be expressed with `_`. -These rules make it possible to cross-build between Scala 2 using the kind projector plugin and Scala 3.0 - 3.2 using the compiler option `-Xkind-projector`. +These rules make it possible to cross-build between Scala 2 using the kind projector plugin and Scala 3.0 - 3.2 using the compiler option `-Ykind-projector`. There is also a migration path for users that want a one-time transition to syntax with `_` as a type parameter placeholder. -With option `-Xkind-projector:underscores` Scala 3 will regard `_` as a type parameter placeholder, leaving `?` as the only syntax for wildcards. +With option `-Ykind-projector:underscores` Scala 3 will regard `_` as a type parameter placeholder, leaving `?` as the only syntax for wildcards. To cross-compile with old Scala 2 sources, while using `_` a placeholder, you must use options `-Xsource:3 -P:kind-projector:underscore-placeholders` together with a recent version of kind-projector (`0.13` and higher) and most recent versions of Scala 2 (`2.13.5` and higher and `2.12.14` and higher) diff --git a/docs/_spec/APPLIEDreference/changed-features/wildcards.md b/docs/_spec/APPLIEDreference/changed-features/wildcards.md index 64d1de69e526..0d3e13c3d7e0 100644 --- a/docs/_spec/APPLIEDreference/changed-features/wildcards.md +++ b/docs/_spec/APPLIEDreference/changed-features/wildcards.md @@ -35,16 +35,16 @@ A step-by-step migration is made possible with the following measures: 4. The Scala 3.1 behavior is already available today under the `-source future` setting. To smooth the transition for codebases that use kind-projector, we adopt the following measures under the command line -option `-Xkind-projector`: +option `-Ykind-projector`: 1. In Scala 3.0, `*` is available as a type parameter placeholder. 2. In Scala 3.2, `*` is deprecated in favor of `_`. A `-rewrite` option is available to rewrite one to the other. 3. In Scala 3.3, `*` is removed again, and all type parameter placeholders will be expressed with `_`. -These rules make it possible to cross build between Scala 2 using the kind projector plugin and Scala 3.0 - 3.2 using the compiler option `-Xkind-projector`. +These rules make it possible to cross build between Scala 2 using the kind projector plugin and Scala 3.0 - 3.2 using the compiler option `-Ykind-projector`. There is also a migration path for users that want a one-time transition to syntax with `_` as a type parameter placeholder. -With option `-Xkind-projector:underscores` Scala 3 will regard `_` as a type parameter placeholder, leaving `?` as the only syntax for wildcards. +With option `-Ykind-projector:underscores` Scala 3 will regard `_` as a type parameter placeholder, leaving `?` as the only syntax for wildcards. To cross-compile with old Scala 2 sources, while using `_` a placeholder, you must use options `-Xsource:3 -P:kind-projector:underscore-placeholders` together with a recent version of kind-projector (`0.13` and higher) and most recent versions of Scala 2 (`2.13.5` and higher and `2.12.14` and higher) diff --git a/scaladoc/src/dotty/tools/scaladoc/snippets/SnippetCompiler.scala b/scaladoc/src/dotty/tools/scaladoc/snippets/SnippetCompiler.scala index 2d8ca15d9c4f..1648dbe2917b 100644 --- a/scaladoc/src/dotty/tools/scaladoc/snippets/SnippetCompiler.scala +++ b/scaladoc/src/dotty/tools/scaladoc/snippets/SnippetCompiler.scala @@ -29,8 +29,8 @@ class SnippetCompiler( val rootCtx = initCtx.fresh.addMode(Mode.ReadPositions).addMode(Mode.Interactive) rootCtx.setSetting(rootCtx.settings.experimental, true) rootCtx.setSetting(rootCtx.settings.YretainTrees, true) - rootCtx.setSetting(rootCtx.settings.YcookComments, true) - rootCtx.setSetting(rootCtx.settings.YreadComments, true) + rootCtx.setSetting(rootCtx.settings.XcookComments, true) + rootCtx.setSetting(rootCtx.settings.XreadComments, true) rootCtx.setSetting(rootCtx.settings.color, "never") rootCtx.setSetting(rootCtx.settings.XimportSuggestionTimeout, 0) diff --git a/scaladoc/src/scala/tasty/inspector/TastyInspector.scala b/scaladoc/src/scala/tasty/inspector/TastyInspector.scala index 03b3aadedc4d..906578c9d405 100644 --- a/scaladoc/src/scala/tasty/inspector/TastyInspector.scala +++ b/scaladoc/src/scala/tasty/inspector/TastyInspector.scala @@ -103,7 +103,7 @@ object TastyInspector: reset() val ctx2 = ctx.fresh .addMode(Mode.ReadPositions) - .setSetting(ctx.settings.YreadComments, true) + .setSetting(ctx.settings.XreadComments, true) new TASTYRun(this, ctx2) new InspectorDriver diff --git a/tasty-inspector/src/scala/tasty/inspector/TastyInspector.scala b/tasty-inspector/src/scala/tasty/inspector/TastyInspector.scala index ea3f0a95dded..7c5476d35940 100644 --- a/tasty-inspector/src/scala/tasty/inspector/TastyInspector.scala +++ b/tasty-inspector/src/scala/tasty/inspector/TastyInspector.scala @@ -100,7 +100,7 @@ object TastyInspector: reset() val ctx2 = ctx.fresh .addMode(Mode.ReadPositions) - .setSetting(ctx.settings.YreadComments, true) + .setSetting(ctx.settings.XreadComments, true) new TASTYRun(this, ctx2) new InspectorDriver From d222bc0dd35166186ca09d7400a919752fc8b1bb Mon Sep 17 00:00:00 2001 From: rochala Date: Tue, 16 Apr 2024 17:44:23 +0200 Subject: [PATCH 05/19] Fix incorrect code in community build project definition --- .../scala/dotty/communitybuild/projects.scala | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/community-build/src/scala/dotty/communitybuild/projects.scala b/community-build/src/scala/dotty/communitybuild/projects.scala index a5797cda0a77..daae054b18c1 100644 --- a/community-build/src/scala/dotty/communitybuild/projects.scala +++ b/community-build/src/scala/dotty/communitybuild/projects.scala @@ -362,7 +362,7 @@ object projects: project = "shapeless-3", sbtTestCommand = "testJVM; testJS", sbtDocCommand = forceDoc("typeable", "deriving"), - scalacOptions = "-source" :: "3.3" :: SbtCommunityProject.scalacOptions.filter(!List("-Ysafe-init", "-Wsafe-init").contains), // due to -Xfatal-warnings + scalacOptions = "-source" :: "3.3" :: SbtCommunityProject.scalacOptions.filter(flag => flag != "-Ysafe-init" && flag != "-Wsafe-init"), // due to -Xfatal-warnings ) lazy val xmlInterpolator = SbtCommunityProject( @@ -429,7 +429,7 @@ object projects: sbtTestCommand = "unitTests/test", // Adds package sbtDocCommand = "coreJVM/doc", - scalacOptions = SbtCommunityProject.scalacOptions.filter(!List("-Ysafe-init", "-Wsafe-init").contains), + scalacOptions = SbtCommunityProject.scalacOptions.filter(flag => flag != "-Ysafe-init" && flag != "-Wsafe-init"), dependencies = List(munit, scodecBits), ) @@ -510,7 +510,7 @@ object projects: project = "discipline", sbtTestCommand = "coreJVM/test;coreJS/test", sbtPublishCommand = "set every credentials := Nil;coreJVM/publishLocal;coreJS/publishLocal", - scalacOptions = SbtCommunityProject.scalacOptions.filter(!List("-Ysafe-init", "-Wsafe-init").contains), + scalacOptions = SbtCommunityProject.scalacOptions.filter(flag => flag != "-Ysafe-init" && flag != "-Wsafe-init"), dependencies = List(scalacheck) ) @@ -526,7 +526,7 @@ object projects: sbtTestCommand = "test", sbtPublishCommand = "coreJVM/publishLocal;coreJS/publishLocal", dependencies = List(discipline), - scalacOptions = SbtCommunityProject.scalacOptions.filter(!List("-Ysafe-init", "-Wsafe-init").contains) + scalacOptions = SbtCommunityProject.scalacOptions.filter(flag => flag != "-Ysafe-init" && flag != "-Wsafe-init") ) lazy val simulacrumScalafixAnnotations = SbtCommunityProject( @@ -540,8 +540,7 @@ object projects: sbtTestCommand = "set Global/scalaJSStage := FastOptStage;rootJVM/test;rootJS/test", sbtPublishCommand = "rootJVM/publishLocal;rootJS/publishLocal", dependencies = List(discipline, disciplineMunit, scalacheck, simulacrumScalafixAnnotations), - scalacOptions = SbtCommunityProject.scalacOptions.filter(!List("-Ysafe-init", "-Wsafe-init").contains) // disable -Ysafe-init or -Wsafe-init, due to -Xfatal-warning - + scalacOptions = SbtCommunityProject.scalacOptions.filter(flag => flag != "-Ysafe-init" && flag != "-Wsafe-init") // disable -Ysafe-init or -Wsafe-init, due to -Xfatal-warning ) lazy val catsMtl = SbtCommunityProject( @@ -656,7 +655,7 @@ object projects: """set actorTests/Compile/scalacOptions -= "-Xfatal-warnings"""", "akka-actor-tests/Test/compile", ).mkString("; "), - scalacOptions = SbtCommunityProject.scalacOptions.filter(!List("-Ysafe-init", "-Wsafe-init").contains), + scalacOptions = SbtCommunityProject.scalacOptions.filter(flag => flag != "-Ysafe-init" && flag != "-Wsafe-init"), dependencies = List(scalatest, scalatestplusJunit, scalatestplusScalacheck) ) @@ -707,7 +706,7 @@ object projects: project = "fs2", sbtTestCommand = "coreJVM/test; coreJS/test", // io/test requires JDK9+ sbtPublishCommand = "coreJVM/publishLocal; coreJS/publishLocal", - scalacOptions = SbtCommunityProject.scalacOptions.filter(!List("-Ysafe-init", "-Wsafe-init").contains), + scalacOptions = SbtCommunityProject.scalacOptions.filter(flag => flag != "-Ysafe-init" && flag != "-Wsafe-init"), dependencies = List(cats, catsEffect3, munitCatsEffect, scalacheckEffect, scodecBits) ) @@ -744,7 +743,7 @@ object projects: project = "http4s", sbtTestCommand = """set ThisBuild / tlFatalWarnings := false; rootJVM/test""", sbtPublishCommand = "publishLocal", - scalacOptions = SbtCommunityProject.scalacOptions.filter(!List("-Ysafe-init", "-Wsafe-init").contains), + scalacOptions = SbtCommunityProject.scalacOptions.filter(flag => flag != "-Ysafe-init" && flag != "-Wsafe-init"), dependencies = List(cats, catsEffect3, fs2, disciplineMunit, scalacheckEffect) ) From 3eabff3e18a452b432fa53722c318d40ac5b9929 Mon Sep 17 00:00:00 2001 From: rochala Date: Tue, 16 Apr 2024 20:08:02 +0200 Subject: [PATCH 06/19] Revert old behaviour of -Xlint --- compiler/src/dotty/tools/dotc/config/ScalaSettings.scala | 4 ++-- compiler/src/dotty/tools/dotc/config/Settings.scala | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala index 35358dc03df6..a7498cf44301 100644 --- a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala +++ b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala @@ -360,7 +360,7 @@ private sealed trait XSettings: val XmacroSettings: Setting[List[String]] = MultiStringSetting(AdvancedSetting, "Xmacro-settings", "setting1,setting2,..settingN", "List of settings which exposed to the macros") // Deprecated - val Xlint: Setting[List[ChoiceWithHelp[String]]] = MultiChoiceHelpSetting( + val Xlint: Setting[List[ChoiceWithHelp[String]]] = UncompleteMultiChoiceHelpSetting( AdvancedSetting, name = "Xlint", helpArg = "advanced warning", @@ -371,7 +371,7 @@ private sealed trait XSettings: ChoiceWithHelp("type-parameter-shadow", "Warn when a type parameter shadows a type already in the scope"), ), default = Nil, - deprecation = Some(Deprecation("Use -Wshadow to enable shadowing lints.", "-Wshadow")) + deprecation = Some(Deprecation("Use -Wshadow to enable shadowing lints.", "-Wshadow")), ) end XSettings diff --git a/compiler/src/dotty/tools/dotc/config/Settings.scala b/compiler/src/dotty/tools/dotc/config/Settings.scala index 80e8c839cef1..eab74276b1ca 100644 --- a/compiler/src/dotty/tools/dotc/config/Settings.scala +++ b/compiler/src/dotty/tools/dotc/config/Settings.scala @@ -375,6 +375,9 @@ object Settings: def MultiChoiceHelpSetting(category: SettingCategory, name: String, helpArg: String, descr: String, choices: List[ChoiceWithHelp[String]], default: List[ChoiceWithHelp[String]], aliases: List[String] = Nil, deprecation: Option[Deprecation] = None): Setting[List[ChoiceWithHelp[String]]] = publish(Setting(category, prependName(name), descr, default, helpArg, Some(choices), aliases = aliases, deprecation = deprecation)) + def UncompleteMultiChoiceHelpSetting(category: SettingCategory, name: String, helpArg: String, descr: String, choices: List[ChoiceWithHelp[String]], default: List[ChoiceWithHelp[String]], aliases: List[String] = Nil, deprecation: Option[Deprecation] = None): Setting[List[ChoiceWithHelp[String]]] = + publish(Setting(category, prependName(name), descr, default, helpArg, Some(choices), aliases = aliases, deprecation = deprecation, ignoreInvalidArgs = true)) + def IntSetting(category: SettingCategory, name: String, descr: String, default: Int, aliases: List[String] = Nil, deprecation: Option[Deprecation] = None): Setting[Int] = publish(Setting(category, prependName(name), descr, default, aliases = aliases, deprecation = deprecation)) From 476ae2dbea8bdead18f8cc0b100c89778a8d3c67 Mon Sep 17 00:00:00 2001 From: rochala Date: Mon, 22 Apr 2024 17:05:40 +0200 Subject: [PATCH 07/19] Refactor settings, only set deprecated flag replacement after validation --- .../scala/dotty/communitybuild/projects.scala | 2 +- compiler/src/dotty/tools/dotc/Run.scala | 2 +- .../tools/dotc/config/ScalaSettings.scala | 19 +++- .../dotty/tools/dotc/config/Settings.scala | 97 ++++++++----------- .../dotty/tools/dotc/transform/Pickler.scala | 2 +- compiler/src/dotty/tools/io/FileWriters.scala | 2 +- .../dotc/config/ScalaSettingsTests.scala | 39 +++++++- .../scala/quoted/staging/QuoteDriver.scala | 8 +- 8 files changed, 103 insertions(+), 68 deletions(-) diff --git a/community-build/src/scala/dotty/communitybuild/projects.scala b/community-build/src/scala/dotty/communitybuild/projects.scala index daae054b18c1..3c1ee7fa2a83 100644 --- a/community-build/src/scala/dotty/communitybuild/projects.scala +++ b/community-build/src/scala/dotty/communitybuild/projects.scala @@ -503,7 +503,7 @@ object projects: project = "verify", sbtTestCommand = "verifyJVM/test", sbtDocCommand = "verifyJVM/doc", - scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Xcheck-macros") // TODO enable -Xcheck-macros + scalacOptions = SbtCommunityProject.scalacOptions.filter(flag != "-Xcheck-macros" && flag != "-Xlint") // TODO enable -Xcheck-macros, wrong flag -Xlint ) lazy val discipline = SbtCommunityProject( diff --git a/compiler/src/dotty/tools/dotc/Run.scala b/compiler/src/dotty/tools/dotc/Run.scala index fa827432460a..11a0430480d9 100644 --- a/compiler/src/dotty/tools/dotc/Run.scala +++ b/compiler/src/dotty/tools/dotc/Run.scala @@ -377,7 +377,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint runCtx.withProgressCallback: cb => _progress = Progress(cb, this, fusedPhases.map(_.traversals).sum) val cancelAsyncTasty: () => Unit = - if !myAsyncTastyWritten && Phases.picklerPhase.exists && !ctx.settings.YearlyTastyOutput.isDefault then + if !myAsyncTastyWritten && Phases.picklerPhase.exists && !ctx.settings.XearlyTastyOutput.isDefault then initializeAsyncTasty() else () => {} diff --git a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala index a7498cf44301..e38ac596061f 100644 --- a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala +++ b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala @@ -359,8 +359,8 @@ private sealed trait XSettings: val XmacroSettings: Setting[List[String]] = MultiStringSetting(AdvancedSetting, "Xmacro-settings", "setting1,setting2,..settingN", "List of settings which exposed to the macros") - // Deprecated - val Xlint: Setting[List[ChoiceWithHelp[String]]] = UncompleteMultiChoiceHelpSetting( + @deprecated(message = "Superseded by -Wshadow, Scheduled for removal in 3.6.0", since = "3.5.0") + val Xlint: Setting[List[ChoiceWithHelp[String]]] = MultiChoiceHelpSetting( AdvancedSetting, name = "Xlint", helpArg = "advanced warning", @@ -467,21 +467,36 @@ private sealed trait YSettings: val YinstrumentDefs: Setting[Boolean] = BooleanSetting(ForkSetting, "Yinstrument-defs", "Add instrumentation code that counts method calls; needs -Yinstrument to be set, too.") // Deprecated: lifted from -Y to -X + @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") val YtermConflict: Setting[String] = ChoiceSetting(ForkSetting, "Yresolve-term-conflict", "strategy", "Resolve term conflicts", List("package", "object", "error"), "error", deprecation = Some(Deprecation("Use -Xresolve-term-conflict instead.", "-Xresolve-term-conflict"))) + @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") val YnoGenericSig: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-generic-signatures", "Suppress generation of generic signatures for Java.", deprecation = Some(Deprecation("Use -Xno-generic-signatures instead.", "-Xno-generic-signatures"))) + @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") val Ydumpclasses: Setting[String] = StringSetting(ForkSetting, "Ydump-classes", "dir", "Dump the generated bytecode to .class files (useful for reflective compilation that utilizes in-memory classloaders).", default = "", deprecation = Some(Deprecation("Use -Xdump-classes instead.", "-Xdump-classes"))) + @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") val YjarCompressionLevel: Setting[Int] = IntChoiceSetting(ForkSetting, "Yjar-compression-level", "compression level to use when writing jar files", Deflater.DEFAULT_COMPRESSION to Deflater.BEST_COMPRESSION, Deflater.DEFAULT_COMPRESSION, deprecation = Some(Deprecation("Use -Xjar-compression-level instead.", "-Xjar-compression-level"))) + @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") val YkindProjector: Setting[String] = ChoiceSetting(ForkSetting, "Ykind-projector", "[underscores, enable, disable]", "Allow `*` as type lambda placeholder to be compatible with kind projector. When invoked as -Ykind-projector:underscores will repurpose `_` to be a type parameter placeholder, this will disable usage of underscore as a wildcard.", List("disable", "", "underscores"), "disable", legacyArgs = true, deprecation = Some(Deprecation("Use -Xkind-projector instead.", "-Xkind-projector"))) + @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") val YdropComments: Setting[Boolean] = BooleanSetting(ForkSetting, "Ydrop-docs", "Drop documentation when scanning source files.", aliases = List("-Ydrop-comments"), deprecation = Some(Deprecation("Use -Xdrop-docs instead.", "-Xdrop-docs"))) + @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") val YcookComments: Setting[Boolean] = BooleanSetting(ForkSetting, "Ycook-docs", "Cook the documentation (type check `@usecase`, etc.)", aliases = List("-Ycook-comments"), deprecation = Some(Deprecation("Use -Xcook-docs instead.", "-Xcook-docs"))) + @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") val YreadComments: Setting[Boolean] = BooleanSetting(ForkSetting, "Yread-docs", "Read documentation from tasty.", deprecation = Some(Deprecation("Use -Xread-docs instead.", "-Xread-docs"))) + @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") val YnoDecodeStacktraces: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-decode-stacktraces", "Show raw StackOverflow stacktraces, instead of decoding them into triggering operations.", deprecation = Some(Deprecation("Use -Xno-decode-stacktraces instead.", "-Xno-decode-stacktraces"))) + @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") val YnoEnrichErrorMessages: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-enrich-error-messages", "Show raw error messages, instead of enriching them with contextual information.", deprecation = Some(Deprecation("Use -Xno-enrich-error-messages instead.", "-Xno-enrich-error-messages"))) + @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") val YdebugMacros: Setting[Boolean] = BooleanSetting(ForkSetting, "Ydebug-macros", "Show debug info when quote pattern match fails", deprecation = Some(Deprecation("Use -Xdebug-macros instead.", "-Xdebug-macros"))) + @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") val YjavaTasty: Setting[Boolean] = BooleanSetting(ForkSetting, "Yjava-tasty", "Pickler phase should compute TASTy for .java defined symbols for use by build tools", aliases = List("-Ypickle-java"), preferPrevious = true, deprecation = Some(Deprecation("Use -Xjava-tasty instead.", "-Xjava-tasty"))) + @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") val YearlyTastyOutput: Setting[AbstractFile] = OutputSetting(ForkSetting, "Yearly-tasty-output", "directory|jar", "Destination to write generated .tasty files to for use in pipelined compilation.", NoAbstractFile, aliases = List("-Ypickle-write"), preferPrevious = true, deprecation = Some(Deprecation("Use -Xearly-tasty-output instead.", "-Xearly-tasty-output"))) + @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") val YallowOutlineFromTasty: Setting[Boolean] = BooleanSetting(ForkSetting, "Yallow-outline-from-tasty", "Allow outline TASTy to be loaded with the -from-tasty option.", deprecation = Some(Deprecation("Use -Xallow-outline-from-tasty instead.", "-Xallow-outline-from-tasty"))) // Deprecated: lifted from -Y to -W + @deprecated(message = "Lifted to -W, Scheduled for removal in 3.6.0", since = "3.5.0") val YcheckInit: Setting[Boolean] = BooleanSetting(ForkSetting, "Ysafe-init", "Ensure safe initialization of objects.", deprecation = Some(Deprecation("Use -Wsafe-init instead.", "-Wsafe-init"))) end YSettings diff --git a/compiler/src/dotty/tools/dotc/config/Settings.scala b/compiler/src/dotty/tools/dotc/config/Settings.scala index eab74276b1ca..9a202d6329c1 100644 --- a/compiler/src/dotty/tools/dotc/config/Settings.scala +++ b/compiler/src/dotty/tools/dotc/config/Settings.scala @@ -53,7 +53,7 @@ object Settings: sstate: SettingsState, arguments: List[String], errors: List[String], - warnings: List[String]) { + warnings: List[String]): def fail(msg: String): Settings.ArgsSummary = ArgsSummary(sstate, arguments.tail, errors :+ msg, warnings) @@ -61,9 +61,8 @@ object Settings: def warn(msg: String): Settings.ArgsSummary = ArgsSummary(sstate, arguments.tail, errors, warnings :+ msg) - def deprecated(msg: String, extraArgs: List[String]): Settings.ArgsSummary = - ArgsSummary(sstate, extraArgs ++ arguments.tail, errors, warnings :+ msg) - } + def deprecated(extraArg: String, msg: String): Settings.ArgsSummary = + ArgsSummary(sstate, extraArg +: arguments.tail, errors, warnings :+ msg) @unshared val settingCharacters = "[a-zA-Z0-9_\\-]*".r @@ -86,8 +85,7 @@ object Settings: propertyClass: Option[Class[?]] = None, deprecation: Option[Deprecation] = None, // kept only for -Xkind-projector option compatibility - legacyArgs: Boolean = false)(private[Settings] val idx: Int - ): + legacyArgs: Boolean = false)(private[Settings] val idx: Int): validateSettingString(prefix.getOrElse(name)) aliases.foreach(validateSettingString) @@ -120,20 +118,28 @@ object Settings: def tryToSet(state: ArgsSummary): ArgsSummary = val ArgsSummary(sstate, arg :: args, errors, warnings) = state: @unchecked + def update(value: Any, args: List[String]): ArgsSummary = - var dangers = warnings - val valueNew = - if sstate.wasChanged(idx) && isMultivalue then - val valueList = value.asInstanceOf[List[String]] - val current = valueIn(sstate).asInstanceOf[List[String]] - valueList.filter(current.contains).foreach(s => dangers :+= s"Setting $name set to $s redundantly") - current ++ valueList - else - if sstate.wasChanged(idx) then - assert(!preferPrevious, "should have shortcutted with ignoreValue, side-effect may be present!") - dangers :+= s"Flag $name set repeatedly" - value - ArgsSummary(updateIn(sstate, valueNew), args, errors, dangers) + deprecation match + case Some(Deprecation(msg, replacedBy)) => + val deprecatedMsg = s"Option $name is deprecated: $msg" + if argValRest.isBlank() then state.deprecated(replacedBy, deprecatedMsg) + else state.deprecated(s"$replacedBy:$argValRest", deprecatedMsg) + + case None => + var dangers = warnings + val valueNew = + if sstate.wasChanged(idx) && isMultivalue then + val valueList = value.asInstanceOf[List[String]] + val current = valueIn(sstate).asInstanceOf[List[String]] + valueList.filter(current.contains).foreach(s => dangers :+= s"Setting $name set to $s redundantly") + current ++ valueList + else + if sstate.wasChanged(idx) then + assert(!preferPrevious, "should have shortcutted with ignoreValue, side-effect may be present!") + dangers :+= s"Flag $name set repeatedly" + value + ArgsSummary(updateIn(sstate, valueNew), args, errors, dangers) end update def ignoreValue(args: List[String]): ArgsSummary = @@ -141,7 +147,7 @@ object Settings: def missingArg = val msg = s"missing argument for option $name" - if ignoreInvalidArgs then state.warn(msg + ", the tag was ignored") else state.fail(msg) + if ignoreInvalidArgs then state.warn(msg + ", the tag was ignored") else state.fail(msg) def invalidChoices(invalid: List[String]) = val msg = s"invalid choice(s) for $name: ${invalid.mkString(",")}" @@ -160,33 +166,30 @@ object Settings: update(argValue, args) def setInt(argValue: String, args: List[String]) = - try - val x = argValue.toInt + argValue.toIntOption.map: intValue => choices match - case Some(r: Range) if x < r.head || r.last < x => + case Some(r: Range) if intValue < r.head || r.last < intValue => state.fail(s"$argValue is out of legal range ${r.head}..${r.last} for $name") - case Some(xs) if !xs.contains(x) => + case Some(xs) if !xs.contains(intValue) => state.fail(s"$argValue is not a valid choice for $name") case _ => - update(x, args) - catch case _: NumberFormatException => + update(intValue, args) + .getOrElse: state.fail(s"$argValue is not an integer argument for $name") def setOutput(argValue: String, args: List[String]) = val path = Directory(argValue) val isJar = path.ext.isJar - if (!isJar && !path.isDirectory) + if (!isJar && !path.isDirectory) then state.fail(s"'$argValue' does not exist or is not a directory or .jar file") - else { + else val output = if (isJar) JarArchive.create(path) else new PlainDirectory(path) update(output, args) - } def setVersion(argValue: String, args: List[String]) = - ScalaVersion.parse(argValue) match { + ScalaVersion.parse(argValue) match case Success(v) => update(v, args) case Failure(ex) => state.fail(ex.getMessage) - } def appendList(strings: List[String], args: List[String]) = choices match @@ -195,9 +198,8 @@ object Settings: case invalid => invalidChoices(invalid) case _ => update(strings, args) - def doSet(argRest: String) = - ((summon[ClassTag[T]], args): @unchecked) match { + ((summon[ClassTag[T]], args): @unchecked) match case (BooleanTag, _) => if sstate.wasChanged(idx) && preferPrevious then ignoreValue(args) else setBoolean(argRest, args) @@ -211,7 +213,6 @@ object Settings: else if argAfterParam then doSetArg(args.head, args.tail) else missingArg - } def doSetArg(arg: String, argsLeft: List[String]) = summon[ClassTag[T]] match case ListTag => @@ -237,17 +238,9 @@ object Settings: def argValRest: String = if(prefix.isEmpty) arg.dropWhile(_ != ':').drop(1) else arg.drop(prefix.get.length) - if matches(arg) then - deprecation match - case Some(Deprecation(msg, replacedBy, mapArguments)) => - val (adjustedOption, state1) = mapArguments(argValRest, state) - val substitutedArg = if adjustedOption.nonEmpty then - s"$replacedBy:$adjustedOption" - else replacedBy - state1.deprecated(s"Option $name is deprecated: $msg", List(substitutedArg)) - case None => doSet(argValRest) - else - state + if matches(arg) then doSet(argValRest) + else state + end tryToSet end Setting @@ -258,14 +251,10 @@ object Settings: * * @param msg deprecation message that will be displayed in following format: s"Option $name is deprecated: $msg" * @param replacedBy option that is substituting current option - * @param updateChoices a function used to map available options to different ones with access to the state. - * It allows to append additional warnings or failing the compilation depending on the case e.g. - * when there is no option that can be replace deprecated one. */ case class Deprecation( msg: String, replacedBy: String, - updateChoices: (String, ArgsSummary) => (String, ArgsSummary) = (option, state) => (option, state) ) object Setting: @@ -287,7 +276,7 @@ object Settings: s"\n- $name${if description.isEmpty() then "" else s" :\n\t${description.replace("\n","\n\t")}"}" end Setting - class SettingGroup { + class SettingGroup: @unshared private val _allSettings = new ArrayBuffer[Setting[?]] @@ -305,11 +294,10 @@ object Settings: userSetSettings(state.sstate).foldLeft(state)(checkDependenciesOfSetting) private def checkDependenciesOfSetting(state: ArgsSummary, setting: Setting[?]) = - setting.depends.foldLeft(state) { (s, dep) => + setting.depends.foldLeft(state): (s, dep) => val (depSetting, reqValue) = dep if (depSetting.valueIn(state.sstate) == reqValue) s else s.fail(s"incomplete option ${setting.name} (requires ${depSetting.name})") - } /** Iterates over the arguments applying them to settings where applicable. * Then verifies setting dependencies are met. @@ -375,9 +363,6 @@ object Settings: def MultiChoiceHelpSetting(category: SettingCategory, name: String, helpArg: String, descr: String, choices: List[ChoiceWithHelp[String]], default: List[ChoiceWithHelp[String]], aliases: List[String] = Nil, deprecation: Option[Deprecation] = None): Setting[List[ChoiceWithHelp[String]]] = publish(Setting(category, prependName(name), descr, default, helpArg, Some(choices), aliases = aliases, deprecation = deprecation)) - def UncompleteMultiChoiceHelpSetting(category: SettingCategory, name: String, helpArg: String, descr: String, choices: List[ChoiceWithHelp[String]], default: List[ChoiceWithHelp[String]], aliases: List[String] = Nil, deprecation: Option[Deprecation] = None): Setting[List[ChoiceWithHelp[String]]] = - publish(Setting(category, prependName(name), descr, default, helpArg, Some(choices), aliases = aliases, deprecation = deprecation, ignoreInvalidArgs = true)) - def IntSetting(category: SettingCategory, name: String, descr: String, default: Int, aliases: List[String] = Nil, deprecation: Option[Deprecation] = None): Setting[Int] = publish(Setting(category, prependName(name), descr, default, aliases = aliases, deprecation = deprecation)) @@ -406,5 +391,5 @@ object Settings: def OptionSetting[T: ClassTag](category: SettingCategory, name: String, descr: String, aliases: List[String] = Nil, deprecation: Option[Deprecation] = None): Setting[Option[T]] = publish(Setting(category, prependName(name), descr, None, propertyClass = Some(summon[ClassTag[T]].runtimeClass), aliases = aliases, deprecation = deprecation)) - } + end SettingGroup end Settings diff --git a/compiler/src/dotty/tools/dotc/transform/Pickler.scala b/compiler/src/dotty/tools/dotc/transform/Pickler.scala index 7507c17cdb74..6c3dcc669877 100644 --- a/compiler/src/dotty/tools/dotc/transform/Pickler.scala +++ b/compiler/src/dotty/tools/dotc/transform/Pickler.scala @@ -131,7 +131,7 @@ object Pickler { * that API and Dependency phases are complete. */ def init(using Context, ExecutionContext): AsyncTastyHolder = - AsyncTastyHolder(ctx.settings.YearlyTastyOutput.value, ctx.incCallback) + AsyncTastyHolder(ctx.settings.XearlyTastyOutput.value, ctx.incCallback) /** Asynchronously writes TASTy files to the destination -Yearly-tasty-output. diff --git a/compiler/src/dotty/tools/io/FileWriters.scala b/compiler/src/dotty/tools/io/FileWriters.scala index 87825b025734..b6338082c696 100644 --- a/compiler/src/dotty/tools/io/FileWriters.scala +++ b/compiler/src/dotty/tools/io/FileWriters.scala @@ -150,7 +150,7 @@ object FileWriters { object ReadOnlyContext: def readSettings(using ctx: Context): ReadOnlySettings = new: - val jarCompressionLevel = ctx.settings.YjarCompressionLevel.value + val jarCompressionLevel = ctx.settings.XjarCompressionLevel.value val debug = ctx.settings.Ydebug.value def readRun(using ctx: Context): ReadOnlyRun = new: diff --git a/compiler/test/dotty/tools/dotc/config/ScalaSettingsTests.scala b/compiler/test/dotty/tools/dotc/config/ScalaSettingsTests.scala index e739c60a8f53..c33002326609 100644 --- a/compiler/test/dotty/tools/dotc/config/ScalaSettingsTests.scala +++ b/compiler/test/dotty/tools/dotc/config/ScalaSettingsTests.scala @@ -13,6 +13,8 @@ import java.net.URI import java.nio.file.Files import scala.util.Using +import scala.annotation.nowarn + class ScalaSettingsTests: @Test def `A setting with aliases is accepted`: Unit = @@ -88,7 +90,8 @@ class ScalaSettingsTests: val nowr = new Diagnostic.Warning("This is a problem.".toMessage, util.NoSourcePosition) assertEquals(Action.Silent, sut.action(nowr)) - @Test def `Lifted options are correctly mapped to their replacements`: Unit = + @nowarn("cat=deprecation") + @Test def `Deprecated options are correctly mapped to their replacements`: Unit = def createTestCase(oldSetting: Setting[_], newSetting: Setting[_], value: String = "") = s"${oldSetting.name}$value" -> newSetting @@ -109,13 +112,44 @@ class ScalaSettingsTests: createTestCase(settings.YearlyTastyOutput , settings.XearlyTastyOutput, ":./"), createTestCase(settings.YallowOutlineFromTasty, settings.XallowOutlineFromTasty), createTestCase(settings.YcheckInit , settings.WcheckInit), + createTestCase(settings.Xlint , settings.Wshadow, ":all"), ).map: (deprecatedArgument, newSetting) => val args = List(deprecatedArgument) val argSummary = ArgsSummary(settings.defaultState, args, errors = Nil, warnings = Nil) val conf = settings.processArguments(argSummary, processAll = true, skipped = Nil) assert(!newSetting.isDefaultIn(conf.sstate), s"Setting $deprecatedArgument was not forwarded to ${newSetting.name}") - @Test def `Lifted options aliases are correctly mapped to their replacements`: Unit = + @nowarn("cat=deprecation") + @Test def `Deprecated options should not be set if old option was incorrect`: Unit = + def createTestCase(oldSetting: Setting[_], newSetting: Setting[_], value: String = ":illegal") = + s"${oldSetting.name}:$value" -> newSetting + + val settings = ScalaSettings + List( + createTestCase(settings.YtermConflict , settings.XtermConflict), + createTestCase(settings.YnoGenericSig , settings.XnoGenericSig), + createTestCase(settings.Ydumpclasses , settings.Xdumpclasses, ""), + createTestCase(settings.YjarCompressionLevel , settings.XjarCompressionLevel), + createTestCase(settings.YkindProjector , settings.XkindProjector), + createTestCase(settings.YdropComments , settings.XdropComments), + createTestCase(settings.YcookComments , settings.XcookComments), + createTestCase(settings.YreadComments , settings.XreadComments), + createTestCase(settings.YnoDecodeStacktraces , settings.XnoDecodeStacktraces), + createTestCase(settings.YnoEnrichErrorMessages, settings.XnoEnrichErrorMessages), + createTestCase(settings.YdebugMacros , settings.XdebugMacros), + createTestCase(settings.YjavaTasty , settings.XjavaTasty), + createTestCase(settings.YearlyTastyOutput , settings.XearlyTastyOutput), + createTestCase(settings.YallowOutlineFromTasty, settings.XallowOutlineFromTasty), + createTestCase(settings.YcheckInit , settings.WcheckInit), + createTestCase(settings.Xlint , settings.Wshadow), + ).map: (deprecatedArgument, newSetting) => + val args = List(deprecatedArgument) + val argSummary = ArgsSummary(settings.defaultState, args, errors = Nil, warnings = Nil) + val conf = settings.processArguments(argSummary, processAll = true, skipped = Nil) + assert(newSetting.isDefaultIn(conf.sstate), s"Setting $deprecatedArgument was forwarded to ${newSetting.name}, when it should be ignored because first option was erroreus") + + @nowarn("cat=deprecation") + @Test def `Deprecated options aliases are correctly mapped to their replacements`: Unit = def createTestCase(oldSetting: Setting[_], newSetting: Setting[_], value: String = "") = oldSetting.aliases.map: alias => s"$alias$value" -> newSetting @@ -137,6 +171,7 @@ class ScalaSettingsTests: createTestCase(settings.YearlyTastyOutput , settings.XearlyTastyOutput, ":./"), createTestCase(settings.YallowOutlineFromTasty, settings.XallowOutlineFromTasty), createTestCase(settings.YcheckInit , settings.WcheckInit), + createTestCase(settings.Xlint , settings.Wshadow, ":all"), ).flatten.map: (deprecatedArgument, newSetting) => val args = List(deprecatedArgument) val argSummary = ArgsSummary(settings.defaultState, args, errors = Nil, warnings = Nil) diff --git a/staging/src/scala/quoted/staging/QuoteDriver.scala b/staging/src/scala/quoted/staging/QuoteDriver.scala index 7eb99bce4ff8..0131a56cd8aa 100644 --- a/staging/src/scala/quoted/staging/QuoteDriver.scala +++ b/staging/src/scala/quoted/staging/QuoteDriver.scala @@ -41,7 +41,7 @@ private class QuoteDriver(appClassloader: ClassLoader) extends Driver: setCompilerSettings(ctx1.fresh.setSetting(ctx1.settings.outputDir, outDir), settings) } - val compiledExpr = + val compiledExpr = try new QuoteCompiler().newRun(ctx).compileExpr(exprBuilder) catch case ex: dotty.tools.FatalError => @@ -50,10 +50,10 @@ private class QuoteDriver(appClassloader: ClassLoader) extends Driver: |This might be caused by using an incorrect classloader |when creating the `staging.Compiler` instance with `staging.Compiler.make`. |For details, please refer to the documentation. - |For non-enriched exceptions, compile with -Yno-enrich-error-messages.""".stripMargin - if ctx.settings.YnoEnrichErrorMessages.value(using ctx) then throw ex + |For non-enriched exceptions, compile with -Xno-enrich-error-messages.""".stripMargin + if ctx.settings.XnoEnrichErrorMessages.value(using ctx) then throw ex else throw new Exception(enrichedMessage, ex) - + compiledExpr match case Right(value) => value.asInstanceOf[T] From b050fd0ac300a27423cdbe10566b7994aff73e18 Mon Sep 17 00:00:00 2001 From: rochala Date: Sat, 27 Apr 2024 09:29:46 +0200 Subject: [PATCH 08/19] Make arguments being lazy evaluated to avoid side effects --- .../dotty/tools/dotc/config/Settings.scala | 40 ++++++++++++------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/config/Settings.scala b/compiler/src/dotty/tools/dotc/config/Settings.scala index 9a202d6329c1..08a8e9936f3d 100644 --- a/compiler/src/dotty/tools/dotc/config/Settings.scala +++ b/compiler/src/dotty/tools/dotc/config/Settings.scala @@ -119,14 +119,23 @@ object Settings: def tryToSet(state: ArgsSummary): ArgsSummary = val ArgsSummary(sstate, arg :: args, errors, warnings) = state: @unchecked - def update(value: Any, args: List[String]): ArgsSummary = + /** + * Updates the value in state + * + * @param getValue it is crucial that this argument is passed by name, as [setOutput] have side effects. + * @param argStringValue string value of currently proccessed argument that will be used to set deprecation replacement + * @param args remaining arguments to process + * @return new argumment state + */ + def update(getValue: => Any, argStringValue: String, args: List[String]): ArgsSummary = deprecation match case Some(Deprecation(msg, replacedBy)) => val deprecatedMsg = s"Option $name is deprecated: $msg" - if argValRest.isBlank() then state.deprecated(replacedBy, deprecatedMsg) - else state.deprecated(s"$replacedBy:$argValRest", deprecatedMsg) + if argStringValue.isEmpty then state.deprecated(replacedBy, deprecatedMsg) + else state.deprecated(s"$replacedBy:$argStringValue", deprecatedMsg) case None => + val value = getValue var dangers = warnings val valueNew = if sstate.wasChanged(idx) && isMultivalue then @@ -154,8 +163,8 @@ object Settings: if ignoreInvalidArgs then state.warn(msg + ", the tag was ignored") else state.fail(msg) def setBoolean(argValue: String, args: List[String]) = - if argValue.equalsIgnoreCase("true") || argValue.isEmpty then update(true, args) - else if argValue.equalsIgnoreCase("false") then update(false, args) + if argValue.equalsIgnoreCase("true") || argValue.isEmpty then update(true, argValue, args) + else if argValue.equalsIgnoreCase("false") then update(false, argValue, args) else state.fail(s"$argValue is not a valid choice for boolean setting $name") def setString(argValue: String, args: List[String]) = @@ -163,7 +172,7 @@ object Settings: case Some(xs) if !xs.contains(argValue) => state.fail(s"$argValue is not a valid choice for $name") case _ => - update(argValue, args) + update(argValue, argValue, args) def setInt(argValue: String, args: List[String]) = argValue.toIntOption.map: intValue => @@ -173,7 +182,7 @@ object Settings: case Some(xs) if !xs.contains(intValue) => state.fail(s"$argValue is not a valid choice for $name") case _ => - update(intValue, args) + update(intValue, argValue, args) .getOrElse: state.fail(s"$argValue is not an integer argument for $name") @@ -183,20 +192,21 @@ object Settings: if (!isJar && !path.isDirectory) then state.fail(s"'$argValue' does not exist or is not a directory or .jar file") else - val output = if (isJar) JarArchive.create(path) else new PlainDirectory(path) - update(output, args) + /* Side effect, do not change this method to evaluate eagerly */ + def output = if (isJar) JarArchive.create(path) else new PlainDirectory(path) + update(output, argValue, args) def setVersion(argValue: String, args: List[String]) = ScalaVersion.parse(argValue) match - case Success(v) => update(v, args) + case Success(v) => update(v, argValue, args) case Failure(ex) => state.fail(ex.getMessage) - def appendList(strings: List[String], args: List[String]) = + def appendList(strings: List[String], argValue: String, args: List[String]) = choices match case Some(valid) => strings.filterNot(valid.contains) match - case Nil => update(strings, args) + case Nil => update(strings, argValue, args) case invalid => invalidChoices(invalid) - case _ => update(strings, args) + case _ => update(strings, argValue, args) def doSet(argRest: String) = ((summon[ClassTag[T]], args): @unchecked) match @@ -204,7 +214,7 @@ object Settings: if sstate.wasChanged(idx) && preferPrevious then ignoreValue(args) else setBoolean(argRest, args) case (OptionTag, _) => - update(Some(propertyClass.get.getConstructor().newInstance()), args) + update(Some(propertyClass.get.getConstructor().newInstance()), "", args) case (ct, args) => val argInArgRest = !argRest.isEmpty || legacyArgs val argAfterParam = !argInArgRest && args.nonEmpty && (ct == IntTag || !args.head.startsWith("-")) @@ -217,7 +227,7 @@ object Settings: def doSetArg(arg: String, argsLeft: List[String]) = summon[ClassTag[T]] match case ListTag => val strings = arg.split(",").toList - appendList(strings, argsLeft) + appendList(strings, arg, argsLeft) case StringTag => setString(arg, argsLeft) case OutputTag => From 52a1b382d0646398fa5630517e995590a6afa720 Mon Sep 17 00:00:00 2001 From: rochala Date: Sat, 27 Apr 2024 11:44:44 +0200 Subject: [PATCH 09/19] Add tests that verify parsing and output behaviour --- .../tools/dotc/config/ScalaSettings.scala | 19 +-- .../test/dotty/tools/dotc/SettingsTests.scala | 128 +++++++++++++++++- .../dotc/config/ScalaSettingsTests.scala | 18 +-- 3 files changed, 145 insertions(+), 20 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala index e38ac596061f..35299b905de5 100644 --- a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala +++ b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala @@ -340,9 +340,9 @@ private sealed trait XSettings: val XdebugMacros: Setting[Boolean] = BooleanSetting(AdvancedSetting, "Xdebug-macros", "Show debug info when quote pattern match fails") /** Pipeline compilation options */ - val XjavaTasty: Setting[Boolean] = BooleanSetting(AdvancedSetting, "Xjava-tasty", "Pickler phase should compute TASTy for .java defined symbols for use by build tools", aliases = List("-Xpickle-java"), preferPrevious = true) - val XearlyTastyOutput: Setting[AbstractFile] = OutputSetting(AdvancedSetting, "Xearly-tasty-output", "directory|jar", "Destination to write generated .tasty files to for use in pipelined compilation.", NoAbstractFile, aliases = List("-Xpickle-write"), preferPrevious = true) - val XallowOutlineFromTasty: Setting[Boolean] = BooleanSetting(AdvancedSetting, "Xallow-outline-from-tasty", "Allow outline TASTy to be loaded with the -from-tasty option.") + val XjavaTasty: Setting[Boolean] = BooleanSetting(AdvancedSetting, "Xjava-tasty", "Pickler phase should compute TASTy for .java defined symbols for use by build tools", aliases = List("-Xpickle-java", "-Yjava-tasty", "-Ypickle-java"), preferPrevious = true) + val XearlyTastyOutput: Setting[AbstractFile] = OutputSetting(AdvancedSetting, "Xearly-tasty-output", "directory|jar", "Destination to write generated .tasty files to for use in pipelined compilation.", NoAbstractFile, aliases = List("-Xpickle-write", "-Yearly-tasty-output", "-Ypickle-write"), preferPrevious = true) + val XallowOutlineFromTasty: Setting[Boolean] = BooleanSetting(AdvancedSetting, "Xallow-outline-from-tasty", "Allow outline TASTy to be loaded with the -from-tasty option.", aliases = List("-Yallow-outline-from-tasty")) val XmixinForceForwarders = ChoiceSetting( AdvancedSetting, @@ -489,12 +489,13 @@ private sealed trait YSettings: val YnoEnrichErrorMessages: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-enrich-error-messages", "Show raw error messages, instead of enriching them with contextual information.", deprecation = Some(Deprecation("Use -Xno-enrich-error-messages instead.", "-Xno-enrich-error-messages"))) @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") val YdebugMacros: Setting[Boolean] = BooleanSetting(ForkSetting, "Ydebug-macros", "Show debug info when quote pattern match fails", deprecation = Some(Deprecation("Use -Xdebug-macros instead.", "-Xdebug-macros"))) - @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") - val YjavaTasty: Setting[Boolean] = BooleanSetting(ForkSetting, "Yjava-tasty", "Pickler phase should compute TASTy for .java defined symbols for use by build tools", aliases = List("-Ypickle-java"), preferPrevious = true, deprecation = Some(Deprecation("Use -Xjava-tasty instead.", "-Xjava-tasty"))) - @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") - val YearlyTastyOutput: Setting[AbstractFile] = OutputSetting(ForkSetting, "Yearly-tasty-output", "directory|jar", "Destination to write generated .tasty files to for use in pipelined compilation.", NoAbstractFile, aliases = List("-Ypickle-write"), preferPrevious = true, deprecation = Some(Deprecation("Use -Xearly-tasty-output instead.", "-Xearly-tasty-output"))) - @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") - val YallowOutlineFromTasty: Setting[Boolean] = BooleanSetting(ForkSetting, "Yallow-outline-from-tasty", "Allow outline TASTy to be loaded with the -from-tasty option.", deprecation = Some(Deprecation("Use -Xallow-outline-from-tasty instead.", "-Xallow-outline-from-tasty"))) + + // @deprecated(message = "Lifted to -X, Scheduled for removal in 3.8.0", since = "3.7.0") + // val YjavaTasty: Setting[Boolean] = BooleanSetting(ForkSetting, "Yjava-tasty", "Pickler phase should compute TASTy for .java defined symbols for use by build tools", aliases = List("-Ypickle-java"), preferPrevious = true, deprecation = Some(Deprecation("Use -Xjava-tasty instead.", "-Xjava-tasty"))) + // @deprecated(message = "Lifted to -X, Scheduled for removal in 3.8.0", since = "3.7.0") + // val YearlyTastyOutput: Setting[AbstractFile] = OutputSetting(ForkSetting, "Yearly-tasty-output", "directory|jar", "Destination to write generated .tasty files to for use in pipelined compilation.", NoAbstractFile, aliases = List("-Ypickle-write"), preferPrevious = true, deprecation = Some(Deprecation("Use -Xearly-tasty-output instead.", "-Xearly-tasty-output"))) + // @deprecated(message = "Lifted to -X, Scheduled for removal in 3.8.0", since = "3.7.0") + // val YallowOutlineFromTasty: Setting[Boolean] = BooleanSetting(ForkSetting, "Yallow-outline-from-tasty", "Allow outline TASTy to be loaded with the -from-tasty option.", deprecation = Some(Deprecation("Use -Xallow-outline-from-tasty instead.", "-Xallow-outline-from-tasty"))) // Deprecated: lifted from -Y to -W @deprecated(message = "Lifted to -W, Scheduled for removal in 3.6.0", since = "3.5.0") diff --git a/compiler/test/dotty/tools/dotc/SettingsTests.scala b/compiler/test/dotty/tools/dotc/SettingsTests.scala index 8125a80f29f8..24c97dba60b1 100644 --- a/compiler/test/dotty/tools/dotc/SettingsTests.scala +++ b/compiler/test/dotty/tools/dotc/SettingsTests.scala @@ -7,14 +7,19 @@ import reporting.StoreReporter import vulpix.TestConfiguration import core.Contexts.{Context, ContextBase} -import dotty.tools.dotc.config.Settings._ -import dotty.tools.dotc.config.ScalaSettingCategories._ +import dotty.tools.dotc.config.Settings.* +import dotty.tools.dotc.config.Settings.Setting.ChoiceWithHelp +import dotty.tools.dotc.config.ScalaSettingCategories.* import dotty.tools.vulpix.TestConfiguration.mkClasspath +import dotty.tools.io.PlainDirectory +import dotty.tools.io.Directory +import dotty.tools.dotc.config.ScalaVersion import java.nio.file._ import org.junit.Test import org.junit.Assert._ +import scala.util.Using class SettingsTests { @@ -199,6 +204,125 @@ class SettingsTests { assertEquals(List("Flag -qux set repeatedly"), summary.warnings) } + @Test def `Output setting is overriding existing jar`: Unit = + val result = Using.resource(Files.createTempFile("myfile", ".jar").nn){ file => + object Settings extends SettingGroup: + val defaultDir = new PlainDirectory(Directory(".")) + val testOutput = OutputSetting(RootSetting, "testOutput", "testOutput", "", defaultDir) + + import Settings._ + + val creationTime = Files.getLastModifiedTime(file) + val args = List(s"-testOutput:${file.toString}") + val summary = processArguments(args, processAll = true) + + val creationTimeAfterProcessing = Files.getLastModifiedTime(file) + + assert(creationTimeAfterProcessing.toMillis > creationTime.toMillis, "Jar should have been overriden") + + }(Files.deleteIfExists(_)) + + @Test def `Output setting is respecting previous setting`: Unit = + val result = Using.resources( + Files.createTempFile("myfile", ".jar").nn, Files.createTempFile("myfile2", ".jar").nn + ){ (file1, file2) => + object Settings extends SettingGroup: + val defaultDir = new PlainDirectory(Directory(".")) + val testOutput = OutputSetting(RootSetting, "testOutput", "testOutput", "", defaultDir, preferPrevious = true) + + import Settings._ + + Files.writeString(file1, "test1") + Files.writeString(file2, "test2") + + val file1StateBefore = Files.readString(file1) + val file2StateBefore = Files.readString(file2) + + val creationTime = Files.getLastModifiedTime(file1) + val args = List(s"-testOutput:${file1.toString}", s"-testOutput:${file2.toString}") + val summary = processArguments(args, processAll = true) + + // The output is a new filesystem without information of original path + // We can't check the `testOutput.value` as in other tests. + assertNotEquals(file1StateBefore, Files.readString(file1)) + assertEquals(file2StateBefore, Files.readString(file2)) + + }(Files.deleteIfExists(_), Files.deleteIfExists(_)) + + @Test def `Output side effect is not present when setting is deprecated`: Unit = + val result = Using.resource(Files.createTempFile("myfile", ".jar").nn){ file => + object Settings extends SettingGroup: + val defaultDir = new PlainDirectory(Directory(".")) + val testOutput = OutputSetting(RootSetting, "testOutput", "testOutput", "", defaultDir, preferPrevious = true, deprecation = Some(Deprecation("deprecated", "XtestOutput"))) + + import Settings._ + + val creationTime = Files.getLastModifiedTime(file) + val args = List(s"-testOutput:${file.toString}") + val summary = processArguments(args, processAll = true) + + val creationTimeAfterProcessing = Files.getLastModifiedTime(file) + + assertEquals(creationTimeAfterProcessing, creationTime) + + }(Files.deleteIfExists(_)) + + @Test def `Arguments of flags are correctly parsed with both ":" and " " separating`: Unit = + object Settings extends SettingGroup: + val booleanSetting = BooleanSetting(RootSetting, "booleanSetting", "booleanSetting", false) + val stringSetting = StringSetting(RootSetting, "stringSetting", "stringSetting", "", "test") + val choiceSetting = ChoiceSetting(RootSetting, "choiceSetting", "choiceSetting", "", List("a", "b"), "a") + val multiChoiceSetting= MultiChoiceSetting(RootSetting, "multiChoiceSetting", "multiChoiceSetting", "", List("a", "b"), List()) + val multiChoiceHelpSetting= MultiChoiceHelpSetting(RootSetting, "multiChoiceHelpSetting", "multiChoiceHelpSetting", "", List(ChoiceWithHelp("a", "a"), ChoiceWithHelp("b", "b")), List()) + val intSetting = IntSetting(RootSetting, "intSetting", "intSetting", 0) + val intChoiceSetting = IntChoiceSetting(RootSetting, "intChoiceSetting", "intChoiceSetting", List(1,2,3), 1) + val multiStringSetting = MultiStringSetting(RootSetting, "multiStringSetting", "multiStringSetting", "", List("a", "b"), List()) + val outputSetting = OutputSetting(RootSetting, "outputSetting", "outputSetting", "", new PlainDirectory(Directory("."))) + val pathSetting = PathSetting(RootSetting, "pathSetting", "pathSetting", ".") + val phasesSetting = PhasesSetting(RootSetting, "phasesSetting", "phasesSetting", "all") + val versionSetting= VersionSetting(RootSetting, "versionSetting", "versionSetting") + + import Settings._ + Using.resource(Files.createTempDirectory("testDir")) { dir => + + val args = List( + List("-booleanSetting", "true"), + List("-stringSetting", "newTest"), + List("-choiceSetting", "b"), + List("-multiChoiceSetting", "a,b"), + List("-multiChoiceHelpSetting", "a,b"), + List("-intSetting", "42"), + List("-intChoiceSetting", "2"), + List("-multiStringSetting", "a,b"), + List("-outputSetting", dir.toString), + List("-pathSetting", dir.toString), + List("-phasesSetting", "parser,typer"), + List("-versionSetting", "1.0.0"), + ) + + def testValues(summary: ArgsSummary) = + withProcessedArgs(summary) { + assertEquals(true, booleanSetting.value) + assertEquals("newTest", stringSetting.value) + assertEquals("b", choiceSetting.value) + assertEquals(List("a", "b"), multiChoiceSetting.value) + assertEquals(List("a", "b"), multiChoiceHelpSetting.value) + assertEquals(42, intSetting.value) + assertEquals(2, intChoiceSetting.value) + assertEquals(List("a", "b"), multiStringSetting.value) + assertEquals(dir.toString, outputSetting.value.path) + assertEquals(dir.toString, pathSetting.value) + assertEquals(List("parser", "typer"), phasesSetting.value) + assertEquals(ScalaVersion.parse("1.0.0").get, versionSetting.value) + } + + val summaryColon = processArguments(args.map(_.mkString(":")), processAll = true) + val summaryWhitespace = processArguments(args.flatten, processAll = true) + testValues(summary = summaryColon) + testValues(summary = summaryWhitespace) + + }(Files.deleteIfExists(_)) + private def withProcessedArgs(summary: ArgsSummary)(f: SettingsState ?=> Unit) = f(using summary.sstate) extension [T](setting: Setting[T]) diff --git a/compiler/test/dotty/tools/dotc/config/ScalaSettingsTests.scala b/compiler/test/dotty/tools/dotc/config/ScalaSettingsTests.scala index c33002326609..9ebde841c50b 100644 --- a/compiler/test/dotty/tools/dotc/config/ScalaSettingsTests.scala +++ b/compiler/test/dotty/tools/dotc/config/ScalaSettingsTests.scala @@ -108,9 +108,9 @@ class ScalaSettingsTests: createTestCase(settings.YnoDecodeStacktraces , settings.XnoDecodeStacktraces), createTestCase(settings.YnoEnrichErrorMessages, settings.XnoEnrichErrorMessages), createTestCase(settings.YdebugMacros , settings.XdebugMacros), - createTestCase(settings.YjavaTasty , settings.XjavaTasty), - createTestCase(settings.YearlyTastyOutput , settings.XearlyTastyOutput, ":./"), - createTestCase(settings.YallowOutlineFromTasty, settings.XallowOutlineFromTasty), + // createTestCase(settings.YjavaTasty , settings.XjavaTasty), + // createTestCase(settings.YearlyTastyOutput , settings.XearlyTastyOutput, ":./"), + // createTestCase(settings.YallowOutlineFromTasty, settings.XallowOutlineFromTasty), createTestCase(settings.YcheckInit , settings.WcheckInit), createTestCase(settings.Xlint , settings.Wshadow, ":all"), ).map: (deprecatedArgument, newSetting) => @@ -137,9 +137,9 @@ class ScalaSettingsTests: createTestCase(settings.YnoDecodeStacktraces , settings.XnoDecodeStacktraces), createTestCase(settings.YnoEnrichErrorMessages, settings.XnoEnrichErrorMessages), createTestCase(settings.YdebugMacros , settings.XdebugMacros), - createTestCase(settings.YjavaTasty , settings.XjavaTasty), - createTestCase(settings.YearlyTastyOutput , settings.XearlyTastyOutput), - createTestCase(settings.YallowOutlineFromTasty, settings.XallowOutlineFromTasty), + // createTestCase(settings.YjavaTasty , settings.XjavaTasty), + // createTestCase(settings.YearlyTastyOutput , settings.XearlyTastyOutput), + // createTestCase(settings.YallowOutlineFromTasty, settings.XallowOutlineFromTasty), createTestCase(settings.YcheckInit , settings.WcheckInit), createTestCase(settings.Xlint , settings.Wshadow), ).map: (deprecatedArgument, newSetting) => @@ -167,9 +167,9 @@ class ScalaSettingsTests: createTestCase(settings.YnoDecodeStacktraces , settings.XnoDecodeStacktraces), createTestCase(settings.YnoEnrichErrorMessages, settings.XnoEnrichErrorMessages), createTestCase(settings.YdebugMacros , settings.XdebugMacros), - createTestCase(settings.YjavaTasty , settings.XjavaTasty), - createTestCase(settings.YearlyTastyOutput , settings.XearlyTastyOutput, ":./"), - createTestCase(settings.YallowOutlineFromTasty, settings.XallowOutlineFromTasty), + // createTestCase(settings.YjavaTasty , settings.XjavaTasty), + // createTestCase(settings.YearlyTastyOutput , settings.XearlyTastyOutput, ":./"), + // createTestCase(settings.YallowOutlineFromTasty, settings.XallowOutlineFromTasty), createTestCase(settings.YcheckInit , settings.WcheckInit), createTestCase(settings.Xlint , settings.Wshadow, ":all"), ).flatten.map: (deprecatedArgument, newSetting) => From bb501ea88a1fd5463f4b24bbf3d4580eb437a500 Mon Sep 17 00:00:00 2001 From: rochala Date: Sat, 27 Apr 2024 12:23:57 +0200 Subject: [PATCH 10/19] Use jvm 8 compatible API, refactor deprecation, schedule YoutputOnlyTasty for removal --- .../scala/dotty/communitybuild/projects.scala | 2 +- .../jvm/PostProcessorFrontendAccess.scala | 2 + .../tools/dotc/config/ScalaSettings.scala | 37 ++++++++++--------- .../dotty/tools/dotc/config/Settings.scala | 19 ++++++---- .../test/dotty/tools/dotc/SettingsTests.scala | 14 +++---- 5 files changed, 42 insertions(+), 32 deletions(-) diff --git a/community-build/src/scala/dotty/communitybuild/projects.scala b/community-build/src/scala/dotty/communitybuild/projects.scala index 3c1ee7fa2a83..33dc39379a63 100644 --- a/community-build/src/scala/dotty/communitybuild/projects.scala +++ b/community-build/src/scala/dotty/communitybuild/projects.scala @@ -503,7 +503,7 @@ object projects: project = "verify", sbtTestCommand = "verifyJVM/test", sbtDocCommand = "verifyJVM/doc", - scalacOptions = SbtCommunityProject.scalacOptions.filter(flag != "-Xcheck-macros" && flag != "-Xlint") // TODO enable -Xcheck-macros, wrong flag -Xlint + scalacOptions = SbtCommunityProject.scalacOptions.filter(flag => flag != "-Xcheck-macros" && flag != "-Xlint") // TODO enable -Xcheck-macros, wrong flag -Xlint ) lazy val discipline = SbtCommunityProject( diff --git a/compiler/src/dotty/tools/backend/jvm/PostProcessorFrontendAccess.scala b/compiler/src/dotty/tools/backend/jvm/PostProcessorFrontendAccess.scala index 41749967389e..e1b2120fa848 100644 --- a/compiler/src/dotty/tools/backend/jvm/PostProcessorFrontendAccess.scala +++ b/compiler/src/dotty/tools/backend/jvm/PostProcessorFrontendAccess.scala @@ -127,6 +127,8 @@ object PostProcessorFrontendAccess { override val jarCompressionLevel: Int = s.XjarCompressionLevel.value override val backendParallelism: Int = s.YbackendParallelism.value override val backendMaxWorkerQueue: Option[Int] = s.YbackendWorkerQueue.valueSetByUser + + @annotation.nowarn("cat=deprecation") override val outputOnlyTasty: Boolean = s.YoutputOnlyTasty.value } diff --git a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala index 35299b905de5..858c844a6855 100644 --- a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala +++ b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala @@ -371,7 +371,7 @@ private sealed trait XSettings: ChoiceWithHelp("type-parameter-shadow", "Warn when a type parameter shadows a type already in the scope"), ), default = Nil, - deprecation = Some(Deprecation("Use -Wshadow to enable shadowing lints.", "-Wshadow")), + deprecation = Deprecation.renamed("-Wshadow"), ) end XSettings @@ -434,7 +434,6 @@ private sealed trait YSettings: val YfromTastyIgnoreList: Setting[List[String]] = MultiStringSetting(ForkSetting, "Yfrom-tasty-ignore-list", "file", "List of `tasty` files in jar files that will not be loaded when using -from-tasty.") val YlegacyLazyVals: Setting[Boolean] = BooleanSetting(ForkSetting, "Ylegacy-lazy-vals", "Use legacy (pre 3.3.0) implementation of lazy vals.") val YcompileScala2Library: Setting[Boolean] = BooleanSetting(ForkSetting, "Ycompile-scala2-library", "Used when compiling the Scala 2 standard library.") - val YoutputOnlyTasty: Setting[Boolean] = BooleanSetting(ForkSetting, "Youtput-only-tasty", "Used to only generate the TASTy file without the classfiles") val YprofileEnabled: Setting[Boolean] = BooleanSetting(ForkSetting, "Yprofile-enabled", "Enable profiling.") val YprofileDestination: Setting[String] = StringSetting(ForkSetting, "Yprofile-destination", "file", "Where to send profiling output - specify a file, default is to the console.", "") //.withPostSetHook( _ => YprofileEnabled.value = true ) @@ -468,36 +467,40 @@ private sealed trait YSettings: // Deprecated: lifted from -Y to -X @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") - val YtermConflict: Setting[String] = ChoiceSetting(ForkSetting, "Yresolve-term-conflict", "strategy", "Resolve term conflicts", List("package", "object", "error"), "error", deprecation = Some(Deprecation("Use -Xresolve-term-conflict instead.", "-Xresolve-term-conflict"))) + val YtermConflict: Setting[String] = ChoiceSetting(ForkSetting, "Yresolve-term-conflict", "strategy", "Resolve term conflicts", List("package", "object", "error"), "error", deprecation = Deprecation.renamed("-Xresolve-term-conflict")) @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") - val YnoGenericSig: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-generic-signatures", "Suppress generation of generic signatures for Java.", deprecation = Some(Deprecation("Use -Xno-generic-signatures instead.", "-Xno-generic-signatures"))) + val YnoGenericSig: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-generic-signatures", "Suppress generation of generic signatures for Java.", deprecation = Deprecation.renamed("-Xno-generic-signatures")) @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") - val Ydumpclasses: Setting[String] = StringSetting(ForkSetting, "Ydump-classes", "dir", "Dump the generated bytecode to .class files (useful for reflective compilation that utilizes in-memory classloaders).", default = "", deprecation = Some(Deprecation("Use -Xdump-classes instead.", "-Xdump-classes"))) + val Ydumpclasses: Setting[String] = StringSetting(ForkSetting, "Ydump-classes", "dir", "Dump the generated bytecode to .class files (useful for reflective compilation that utilizes in-memory classloaders).", default = "", deprecation = Deprecation.renamed("-Xdump-classes")) @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") - val YjarCompressionLevel: Setting[Int] = IntChoiceSetting(ForkSetting, "Yjar-compression-level", "compression level to use when writing jar files", Deflater.DEFAULT_COMPRESSION to Deflater.BEST_COMPRESSION, Deflater.DEFAULT_COMPRESSION, deprecation = Some(Deprecation("Use -Xjar-compression-level instead.", "-Xjar-compression-level"))) + val YjarCompressionLevel: Setting[Int] = IntChoiceSetting(ForkSetting, "Yjar-compression-level", "compression level to use when writing jar files", Deflater.DEFAULT_COMPRESSION to Deflater.BEST_COMPRESSION, Deflater.DEFAULT_COMPRESSION, deprecation = Deprecation.renamed("-Xjar-compression-level")) @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") - val YkindProjector: Setting[String] = ChoiceSetting(ForkSetting, "Ykind-projector", "[underscores, enable, disable]", "Allow `*` as type lambda placeholder to be compatible with kind projector. When invoked as -Ykind-projector:underscores will repurpose `_` to be a type parameter placeholder, this will disable usage of underscore as a wildcard.", List("disable", "", "underscores"), "disable", legacyArgs = true, deprecation = Some(Deprecation("Use -Xkind-projector instead.", "-Xkind-projector"))) + val YkindProjector: Setting[String] = ChoiceSetting(ForkSetting, "Ykind-projector", "[underscores, enable, disable]", "Allow `*` as type lambda placeholder to be compatible with kind projector. When invoked as -Ykind-projector:underscores will repurpose `_` to be a type parameter placeholder, this will disable usage of underscore as a wildcard.", List("disable", "", "underscores"), "disable", legacyArgs = true, deprecation = Deprecation.renamed("-Xkind-projector")) @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") - val YdropComments: Setting[Boolean] = BooleanSetting(ForkSetting, "Ydrop-docs", "Drop documentation when scanning source files.", aliases = List("-Ydrop-comments"), deprecation = Some(Deprecation("Use -Xdrop-docs instead.", "-Xdrop-docs"))) + val YdropComments: Setting[Boolean] = BooleanSetting(ForkSetting, "Ydrop-docs", "Drop documentation when scanning source files.", aliases = List("-Ydrop-comments"), deprecation = Deprecation.renamed("-Xdrop-docs")) @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") - val YcookComments: Setting[Boolean] = BooleanSetting(ForkSetting, "Ycook-docs", "Cook the documentation (type check `@usecase`, etc.)", aliases = List("-Ycook-comments"), deprecation = Some(Deprecation("Use -Xcook-docs instead.", "-Xcook-docs"))) + val YcookComments: Setting[Boolean] = BooleanSetting(ForkSetting, "Ycook-docs", "Cook the documentation (type check `@usecase`, etc.)", aliases = List("-Ycook-comments"), deprecation = Deprecation.renamed("-Xcook-docs")) @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") - val YreadComments: Setting[Boolean] = BooleanSetting(ForkSetting, "Yread-docs", "Read documentation from tasty.", deprecation = Some(Deprecation("Use -Xread-docs instead.", "-Xread-docs"))) + val YreadComments: Setting[Boolean] = BooleanSetting(ForkSetting, "Yread-docs", "Read documentation from tasty.", deprecation = Deprecation.renamed("-Xread-docs")) @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") - val YnoDecodeStacktraces: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-decode-stacktraces", "Show raw StackOverflow stacktraces, instead of decoding them into triggering operations.", deprecation = Some(Deprecation("Use -Xno-decode-stacktraces instead.", "-Xno-decode-stacktraces"))) + val YnoDecodeStacktraces: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-decode-stacktraces", "Show raw StackOverflow stacktraces, instead of decoding them into triggering operations.", deprecation = Deprecation.renamed("-Xno-decode-stacktraces")) @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") - val YnoEnrichErrorMessages: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-enrich-error-messages", "Show raw error messages, instead of enriching them with contextual information.", deprecation = Some(Deprecation("Use -Xno-enrich-error-messages instead.", "-Xno-enrich-error-messages"))) + val YnoEnrichErrorMessages: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-enrich-error-messages", "Show raw error messages, instead of enriching them with contextual information.", deprecation = Deprecation.renamed("-Xno-enrich-error-messages")) @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") - val YdebugMacros: Setting[Boolean] = BooleanSetting(ForkSetting, "Ydebug-macros", "Show debug info when quote pattern match fails", deprecation = Some(Deprecation("Use -Xdebug-macros instead.", "-Xdebug-macros"))) + val YdebugMacros: Setting[Boolean] = BooleanSetting(ForkSetting, "Ydebug-macros", "Show debug info when quote pattern match fails", deprecation = Deprecation.renamed("-Xdebug-macros")) // @deprecated(message = "Lifted to -X, Scheduled for removal in 3.8.0", since = "3.7.0") - // val YjavaTasty: Setting[Boolean] = BooleanSetting(ForkSetting, "Yjava-tasty", "Pickler phase should compute TASTy for .java defined symbols for use by build tools", aliases = List("-Ypickle-java"), preferPrevious = true, deprecation = Some(Deprecation("Use -Xjava-tasty instead.", "-Xjava-tasty"))) + // val YjavaTasty: Setting[Boolean] = BooleanSetting(ForkSetting, "Yjava-tasty", "Pickler phase should compute TASTy for .java defined symbols for use by build tools", aliases = List("-Ypickle-java"), preferPrevious = true, deprecation = Deprecation.lifted("-Xjava-tasty")) // @deprecated(message = "Lifted to -X, Scheduled for removal in 3.8.0", since = "3.7.0") - // val YearlyTastyOutput: Setting[AbstractFile] = OutputSetting(ForkSetting, "Yearly-tasty-output", "directory|jar", "Destination to write generated .tasty files to for use in pipelined compilation.", NoAbstractFile, aliases = List("-Ypickle-write"), preferPrevious = true, deprecation = Some(Deprecation("Use -Xearly-tasty-output instead.", "-Xearly-tasty-output"))) + // val YearlyTastyOutput: Setting[AbstractFile] = OutputSetting(ForkSetting, "Yearly-tasty-output", "directory|jar", "Destination to write generated .tasty files to for use in pipelined compilation.", NoAbstractFile, aliases = List("-Ypickle-write"), preferPrevious = true, deprecation = Deprecation.lifted("-Xearly-tasty-output")) // @deprecated(message = "Lifted to -X, Scheduled for removal in 3.8.0", since = "3.7.0") - // val YallowOutlineFromTasty: Setting[Boolean] = BooleanSetting(ForkSetting, "Yallow-outline-from-tasty", "Allow outline TASTy to be loaded with the -from-tasty option.", deprecation = Some(Deprecation("Use -Xallow-outline-from-tasty instead.", "-Xallow-outline-from-tasty"))) + // val YallowOutlineFromTasty: Setting[Boolean] = BooleanSetting(ForkSetting, "Yallow-outline-from-tasty", "Allow outline TASTy to be loaded with the -from-tasty option.", deprecation = Deprecation.lifted("-Xallow-outline-from-tasty")) // Deprecated: lifted from -Y to -W @deprecated(message = "Lifted to -W, Scheduled for removal in 3.6.0", since = "3.5.0") - val YcheckInit: Setting[Boolean] = BooleanSetting(ForkSetting, "Ysafe-init", "Ensure safe initialization of objects.", deprecation = Some(Deprecation("Use -Wsafe-init instead.", "-Wsafe-init"))) + val YcheckInit: Setting[Boolean] = BooleanSetting(ForkSetting, "Ysafe-init", "Ensure safe initialization of objects.", deprecation = Deprecation.renamed("-Wsafe-init")) + + // Deprecated: Scheduled for removal + @deprecated(message = "Scheduled for removal in 3.6.0", since = "3.5.0") + val YoutputOnlyTasty: Setting[Boolean] = BooleanSetting(ForkSetting, "Youtput-only-tasty", "Used to only generate the TASTy file without the classfiles", deprecation = Deprecation.removed("3.6.0")) end YSettings diff --git a/compiler/src/dotty/tools/dotc/config/Settings.scala b/compiler/src/dotty/tools/dotc/config/Settings.scala index 08a8e9936f3d..a3b7c50d7d1f 100644 --- a/compiler/src/dotty/tools/dotc/config/Settings.scala +++ b/compiler/src/dotty/tools/dotc/config/Settings.scala @@ -61,8 +61,8 @@ object Settings: def warn(msg: String): Settings.ArgsSummary = ArgsSummary(sstate, arguments.tail, errors, warnings :+ msg) - def deprecated(extraArg: String, msg: String): Settings.ArgsSummary = - ArgsSummary(sstate, extraArg +: arguments.tail, errors, warnings :+ msg) + def deprecated(msg: String, extraArgs: List[String] = Nil): Settings.ArgsSummary = + ArgsSummary(sstate, extraArgs ++ arguments.tail, errors, warnings :+ msg) @unshared val settingCharacters = "[a-zA-Z0-9_\\-]*".r @@ -129,11 +129,12 @@ object Settings: */ def update(getValue: => Any, argStringValue: String, args: List[String]): ArgsSummary = deprecation match - case Some(Deprecation(msg, replacedBy)) => + case Some(Deprecation(msg, Some(replacedBy))) => val deprecatedMsg = s"Option $name is deprecated: $msg" - if argStringValue.isEmpty then state.deprecated(replacedBy, deprecatedMsg) - else state.deprecated(s"$replacedBy:$argStringValue", deprecatedMsg) + if argStringValue.isEmpty then state.deprecated(deprecatedMsg, List(replacedBy)) + else state.deprecated(deprecatedMsg, List(s"$replacedBy:$argStringValue")) + case Some(Deprecation(msg, _)) => state.deprecated(msg) case None => val value = getValue var dangers = warnings @@ -262,11 +263,15 @@ object Settings: * @param msg deprecation message that will be displayed in following format: s"Option $name is deprecated: $msg" * @param replacedBy option that is substituting current option */ - case class Deprecation( + case class Deprecation private( msg: String, - replacedBy: String, + replacedBy: Option[String] = None, ) + object Deprecation: + def renamed(replacement: String) = Some(Deprecation(s"Use $replacement instead.", Some(replacement))) + def removed(removedVersion: String) = Some(Deprecation(s"Scheduled for removal in s$removedVersion", None)) + object Setting: extension [T](setting: Setting[T]) def value(using Context): T = setting.valueIn(ctx.settingsState) diff --git a/compiler/test/dotty/tools/dotc/SettingsTests.scala b/compiler/test/dotty/tools/dotc/SettingsTests.scala index 24c97dba60b1..ba654f66c298 100644 --- a/compiler/test/dotty/tools/dotc/SettingsTests.scala +++ b/compiler/test/dotty/tools/dotc/SettingsTests.scala @@ -232,11 +232,11 @@ class SettingsTests { import Settings._ - Files.writeString(file1, "test1") - Files.writeString(file2, "test2") + Files.write(file1, "test1".getBytes()) + Files.write(file2, "test2".getBytes()) - val file1StateBefore = Files.readString(file1) - val file2StateBefore = Files.readString(file2) + val file1StateBefore = String(Files.readAllBytes(file1)) + val file2StateBefore = String(Files.readAllBytes(file2)) val creationTime = Files.getLastModifiedTime(file1) val args = List(s"-testOutput:${file1.toString}", s"-testOutput:${file2.toString}") @@ -244,8 +244,8 @@ class SettingsTests { // The output is a new filesystem without information of original path // We can't check the `testOutput.value` as in other tests. - assertNotEquals(file1StateBefore, Files.readString(file1)) - assertEquals(file2StateBefore, Files.readString(file2)) + assertNotEquals(file1StateBefore, String(Files.readAllBytes(file1))) + assertEquals(file2StateBefore, String(Files.readAllBytes(file2))) }(Files.deleteIfExists(_), Files.deleteIfExists(_)) @@ -253,7 +253,7 @@ class SettingsTests { val result = Using.resource(Files.createTempFile("myfile", ".jar").nn){ file => object Settings extends SettingGroup: val defaultDir = new PlainDirectory(Directory(".")) - val testOutput = OutputSetting(RootSetting, "testOutput", "testOutput", "", defaultDir, preferPrevious = true, deprecation = Some(Deprecation("deprecated", "XtestOutput"))) + val testOutput = OutputSetting(RootSetting, "testOutput", "testOutput", "", defaultDir, preferPrevious = true, deprecation = Deprecation.renamed("XtestOutput")) import Settings._ From 7bc93b7e46f4225814fa84cc7bfd411a27f928e2 Mon Sep 17 00:00:00 2001 From: rochala Date: Tue, 30 Apr 2024 10:53:28 +0200 Subject: [PATCH 11/19] Make new setting tests deterministic --- .../scala/dotty/communitybuild/projects.scala | 2 +- .../test/dotty/tools/dotc/SettingsTests.scala | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/community-build/src/scala/dotty/communitybuild/projects.scala b/community-build/src/scala/dotty/communitybuild/projects.scala index 33dc39379a63..bff06090ce21 100644 --- a/community-build/src/scala/dotty/communitybuild/projects.scala +++ b/community-build/src/scala/dotty/communitybuild/projects.scala @@ -503,7 +503,7 @@ object projects: project = "verify", sbtTestCommand = "verifyJVM/test", sbtDocCommand = "verifyJVM/doc", - scalacOptions = SbtCommunityProject.scalacOptions.filter(flag => flag != "-Xcheck-macros" && flag != "-Xlint") // TODO enable -Xcheck-macros, wrong flag -Xlint + scalacOptions = SbtCommunityProject.scalacOptions.filter(flag => flag != "-Xcheck-macros") // TODO enable -Xcheck-macros ) lazy val discipline = SbtCommunityProject( diff --git a/compiler/test/dotty/tools/dotc/SettingsTests.scala b/compiler/test/dotty/tools/dotc/SettingsTests.scala index ba654f66c298..301dc10ab54e 100644 --- a/compiler/test/dotty/tools/dotc/SettingsTests.scala +++ b/compiler/test/dotty/tools/dotc/SettingsTests.scala @@ -212,13 +212,13 @@ class SettingsTests { import Settings._ - val creationTime = Files.getLastModifiedTime(file) + Files.write(file, "test".getBytes()) + val fileStateBefore = String(Files.readAllBytes(file)) + val args = List(s"-testOutput:${file.toString}") val summary = processArguments(args, processAll = true) - val creationTimeAfterProcessing = Files.getLastModifiedTime(file) - - assert(creationTimeAfterProcessing.toMillis > creationTime.toMillis, "Jar should have been overriden") + assertNotEquals(fileStateBefore, String(Files.readAllBytes(file)), "Jar should have been overriden") }(Files.deleteIfExists(_)) @@ -257,13 +257,13 @@ class SettingsTests { import Settings._ - val creationTime = Files.getLastModifiedTime(file) + Files.write(file, "test".getBytes()) + val fileStateBefore = String(Files.readAllBytes(file)) + val args = List(s"-testOutput:${file.toString}") val summary = processArguments(args, processAll = true) - val creationTimeAfterProcessing = Files.getLastModifiedTime(file) - - assertEquals(creationTimeAfterProcessing, creationTime) + assertEquals(fileStateBefore, String(Files.readAllBytes(file))) }(Files.deleteIfExists(_)) From 8bbf97fdc85d703fd4d0deeaf3a2600394997dc5 Mon Sep 17 00:00:00 2001 From: rochala Date: Sun, 5 May 2024 13:24:46 +0200 Subject: [PATCH 12/19] Updates to submodules --- community-build/community-projects/discipline | 2 +- community-build/community-projects/scala-stm | 2 +- community-build/community-projects/verify | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/community-build/community-projects/discipline b/community-build/community-projects/discipline index 09c975b18dc0..9dd5f184d67f 160000 --- a/community-build/community-projects/discipline +++ b/community-build/community-projects/discipline @@ -1 +1 @@ -Subproject commit 09c975b18dc0b4e10499fb2922abac82ea8b5252 +Subproject commit 9dd5f184d67f7f1ad21e18d982810445a421165e diff --git a/community-build/community-projects/scala-stm b/community-build/community-projects/scala-stm index 3244edf13c41..cf204977752a 160000 --- a/community-build/community-projects/scala-stm +++ b/community-build/community-projects/scala-stm @@ -1 +1 @@ -Subproject commit 3244edf13c41f22ff8b45143186745e9eb469220 +Subproject commit cf204977752af7ec2ca3b50c43f27daa6a628f49 diff --git a/community-build/community-projects/verify b/community-build/community-projects/verify index ae37d7e153fc..81c1ec3e0d75 160000 --- a/community-build/community-projects/verify +++ b/community-build/community-projects/verify @@ -1 +1 @@ -Subproject commit ae37d7e153fc62d64c40a72c45f810511aef2e01 +Subproject commit 81c1ec3e0d754b221dadb97d81d126338a897271 From f3a91b3f4f1e30ab19a5f31e0222a25bd02ad6d9 Mon Sep 17 00:00:00 2001 From: rochala Date: Mon, 6 May 2024 11:27:55 +0200 Subject: [PATCH 13/19] Properly disable fatal warnings in CI --- community-build/community-projects/discipline | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/community-build/community-projects/discipline b/community-build/community-projects/discipline index 9dd5f184d67f..27016c356287 160000 --- a/community-build/community-projects/discipline +++ b/community-build/community-projects/discipline @@ -1 +1 @@ -Subproject commit 9dd5f184d67f7f1ad21e18d982810445a421165e +Subproject commit 27016c3562871c136e88cc13ffa64a02380265df From 3820f59db097fc8e6ecc7da88175412bc0a9d1a5 Mon Sep 17 00:00:00 2001 From: rochala Date: Mon, 6 May 2024 13:43:49 +0200 Subject: [PATCH 14/19] Updates to submodules --- community-build/community-projects/AsyncFile | 2 +- community-build/community-projects/Equal | 2 +- community-build/community-projects/FingerTree | 2 +- community-build/community-projects/Log | 2 +- community-build/community-projects/Lucre | 2 +- community-build/community-projects/Model | 2 +- community-build/community-projects/Numbers | 2 +- community-build/community-projects/Serial | 2 +- community-build/community-projects/Span | 2 +- community-build/community-projects/discipline | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/community-build/community-projects/AsyncFile b/community-build/community-projects/AsyncFile index d72a5279e4b0..7bdd11657e3e 160000 --- a/community-build/community-projects/AsyncFile +++ b/community-build/community-projects/AsyncFile @@ -1 +1 @@ -Subproject commit d72a5279e4b055ad13d1c19d75939b9bd9d014a0 +Subproject commit 7bdd11657e3e840c31f27140942c8dc9e07ea7b8 diff --git a/community-build/community-projects/Equal b/community-build/community-projects/Equal index 4340d3a6b503..4f357131b4ea 160000 --- a/community-build/community-projects/Equal +++ b/community-build/community-projects/Equal @@ -1 +1 @@ -Subproject commit 4340d3a6b503aad4fbea89ee6026923127e8b1ab +Subproject commit 4f357131b4ea719ba5d09a62dd577a8aab204c4d diff --git a/community-build/community-projects/FingerTree b/community-build/community-projects/FingerTree index 0ed006549a78..eaadc6e0c660 160000 --- a/community-build/community-projects/FingerTree +++ b/community-build/community-projects/FingerTree @@ -1 +1 @@ -Subproject commit 0ed006549a78036aac0b09375e90237e72f599fe +Subproject commit eaadc6e0c660d27fc77a2cb4ab6a265a8e746f97 diff --git a/community-build/community-projects/Log b/community-build/community-projects/Log index 1839754549ed..c55ac4b7a822 160000 --- a/community-build/community-projects/Log +++ b/community-build/community-projects/Log @@ -1 +1 @@ -Subproject commit 1839754549ed690fbba2ea1b220e3f70f8d2ba91 +Subproject commit c55ac4b7a82278f896f25b291e129440d2436fb4 diff --git a/community-build/community-projects/Lucre b/community-build/community-projects/Lucre index 0def1dcb1aa6..1008f0b7f513 160000 --- a/community-build/community-projects/Lucre +++ b/community-build/community-projects/Lucre @@ -1 +1 @@ -Subproject commit 0def1dcb1aa63ba8f398428c000cb2a2f166cca4 +Subproject commit 1008f0b7f51374ddbc947e677c505fa97677b7d4 diff --git a/community-build/community-projects/Model b/community-build/community-projects/Model index d797f70e9d17..fb73627f37d7 160000 --- a/community-build/community-projects/Model +++ b/community-build/community-projects/Model @@ -1 +1 @@ -Subproject commit d797f70e9d178fa6a70d6aa2d3c3324bc1c27b48 +Subproject commit fb73627f37d77d97892a4a0eebe5bd7406559366 diff --git a/community-build/community-projects/Numbers b/community-build/community-projects/Numbers index 656dfd3f7c0a..e19972adb794 160000 --- a/community-build/community-projects/Numbers +++ b/community-build/community-projects/Numbers @@ -1 +1 @@ -Subproject commit 656dfd3f7c0a541b243e2d0f5aabbd20fc8bcea6 +Subproject commit e19972adb7941871e8b1b4a76de0e0c2b4d9fbfc diff --git a/community-build/community-projects/Serial b/community-build/community-projects/Serial index c161cc36e68c..e69b44086955 160000 --- a/community-build/community-projects/Serial +++ b/community-build/community-projects/Serial @@ -1 +1 @@ -Subproject commit c161cc36e68c0d24a508fc9a52a44551c779c682 +Subproject commit e69b44086955023b8747ac10791ad10baad0c5cc diff --git a/community-build/community-projects/Span b/community-build/community-projects/Span index da4c4a9c335c..8d9b4575482e 160000 --- a/community-build/community-projects/Span +++ b/community-build/community-projects/Span @@ -1 +1 @@ -Subproject commit da4c4a9c335c114dbda829150d6476aec830cb84 +Subproject commit 8d9b4575482e103117b3fd2b016c7aaad5962789 diff --git a/community-build/community-projects/discipline b/community-build/community-projects/discipline index 27016c356287..1b75103d8257 160000 --- a/community-build/community-projects/discipline +++ b/community-build/community-projects/discipline @@ -1 +1 @@ -Subproject commit 27016c3562871c136e88cc13ffa64a02380265df +Subproject commit 1b75103d82579e46e799ea6e6c7de1aece137038 From 7f21b829a0e3640ff2bccfb51fafcad3190a013f Mon Sep 17 00:00:00 2001 From: rochala Date: Mon, 6 May 2024 13:52:48 +0200 Subject: [PATCH 15/19] Updates to submodules --- community-build/community-projects/discipline | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/community-build/community-projects/discipline b/community-build/community-projects/discipline index 1b75103d8257..9f519c97c998 160000 --- a/community-build/community-projects/discipline +++ b/community-build/community-projects/discipline @@ -1 +1 @@ -Subproject commit 1b75103d82579e46e799ea6e6c7de1aece137038 +Subproject commit 9f519c97c9980671eb1b80ce1dfb5939bd858418 From 82b7acd34706dbe7d490d551b1e2fb9b569e8903 Mon Sep 17 00:00:00 2001 From: rochala Date: Mon, 6 May 2024 19:30:57 +0200 Subject: [PATCH 16/19] Updates to submodules, remove unnecessary changes, revert Xlint changes --- community-build/community-projects/discipline | 2 +- .../community-projects/discipline-munit | 2 +- .../community-projects/discipline-specs2 | 2 +- community-build/community-projects/fs2 | 2 +- community-build/community-projects/scodec | 2 +- .../community-projects/shapeless-3 | 2 +- community-build/community-projects/verify | 2 +- .../scala/dotty/communitybuild/projects.scala | 16 +++--- .../tools/dotc/config/ScalaSettings.scala | 50 +++++++------------ .../dotty/tools/dotc/config/Settings.scala | 10 ++-- .../dotc/config/ScalaSettingsTests.scala | 4 +- 11 files changed, 43 insertions(+), 51 deletions(-) diff --git a/community-build/community-projects/discipline b/community-build/community-projects/discipline index 9f519c97c998..27016c356287 160000 --- a/community-build/community-projects/discipline +++ b/community-build/community-projects/discipline @@ -1 +1 @@ -Subproject commit 9f519c97c9980671eb1b80ce1dfb5939bd858418 +Subproject commit 27016c3562871c136e88cc13ffa64a02380265df diff --git a/community-build/community-projects/discipline-munit b/community-build/community-projects/discipline-munit index 4e61f1861956..975ae3efaddd 160000 --- a/community-build/community-projects/discipline-munit +++ b/community-build/community-projects/discipline-munit @@ -1 +1 @@ -Subproject commit 4e61f186195660529e7a6f7461b939477735e3f4 +Subproject commit 975ae3efadddaa558435c4c8326628618048fdad diff --git a/community-build/community-projects/discipline-specs2 b/community-build/community-projects/discipline-specs2 index e689c3e809a8..eb9427335a30 160000 --- a/community-build/community-projects/discipline-specs2 +++ b/community-build/community-projects/discipline-specs2 @@ -1 +1 @@ -Subproject commit e689c3e809a89a03cdbbb3a1771e33148715f6c7 +Subproject commit eb9427335a309d6dd1e82632298529ca6a0920fa diff --git a/community-build/community-projects/fs2 b/community-build/community-projects/fs2 index 6d7c6d6924cb..e91c54621b76 160000 --- a/community-build/community-projects/fs2 +++ b/community-build/community-projects/fs2 @@ -1 +1 @@ -Subproject commit 6d7c6d6924cb055028458ac8236622190acf66d1 +Subproject commit e91c54621b762a58c942b6576c42dcd94ba0fc0a diff --git a/community-build/community-projects/scodec b/community-build/community-projects/scodec index b74f2085f071..9b0423b90de9 160000 --- a/community-build/community-projects/scodec +++ b/community-build/community-projects/scodec @@ -1 +1 @@ -Subproject commit b74f2085f07165d84b32c39eb214c9cc838711cc +Subproject commit 9b0423b90de95fc968fafe4543e6b16ef9f81d08 diff --git a/community-build/community-projects/shapeless-3 b/community-build/community-projects/shapeless-3 index 24e86dd290eb..90f0c977b536 160000 --- a/community-build/community-projects/shapeless-3 +++ b/community-build/community-projects/shapeless-3 @@ -1 +1 @@ -Subproject commit 24e86dd290eba9b27599936a7f338fac975f833d +Subproject commit 90f0c977b536c06305496600b8b2014c9e8e3d86 diff --git a/community-build/community-projects/verify b/community-build/community-projects/verify index 81c1ec3e0d75..f82bb3f52623 160000 --- a/community-build/community-projects/verify +++ b/community-build/community-projects/verify @@ -1 +1 @@ -Subproject commit 81c1ec3e0d754b221dadb97d81d126338a897271 +Subproject commit f82bb3f52623e44f02b4b43f8bdf27f4f0a7d3d4 diff --git a/community-build/src/scala/dotty/communitybuild/projects.scala b/community-build/src/scala/dotty/communitybuild/projects.scala index bff06090ce21..ca51db338c84 100644 --- a/community-build/src/scala/dotty/communitybuild/projects.scala +++ b/community-build/src/scala/dotty/communitybuild/projects.scala @@ -362,7 +362,7 @@ object projects: project = "shapeless-3", sbtTestCommand = "testJVM; testJS", sbtDocCommand = forceDoc("typeable", "deriving"), - scalacOptions = "-source" :: "3.3" :: SbtCommunityProject.scalacOptions.filter(flag => flag != "-Ysafe-init" && flag != "-Wsafe-init"), // due to -Xfatal-warnings + scalacOptions = "-source" :: "3.3" :: SbtCommunityProject.scalacOptions.filter(_ != "-Wsafe-init"), // due to -Xfatal-warnings ) lazy val xmlInterpolator = SbtCommunityProject( @@ -429,7 +429,7 @@ object projects: sbtTestCommand = "unitTests/test", // Adds package sbtDocCommand = "coreJVM/doc", - scalacOptions = SbtCommunityProject.scalacOptions.filter(flag => flag != "-Ysafe-init" && flag != "-Wsafe-init"), + scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Wsafe-init"), dependencies = List(munit, scodecBits), ) @@ -503,14 +503,14 @@ object projects: project = "verify", sbtTestCommand = "verifyJVM/test", sbtDocCommand = "verifyJVM/doc", - scalacOptions = SbtCommunityProject.scalacOptions.filter(flag => flag != "-Xcheck-macros") // TODO enable -Xcheck-macros + scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Xcheck-macros") // TODO enable -Xcheck-macros ) lazy val discipline = SbtCommunityProject( project = "discipline", sbtTestCommand = "coreJVM/test;coreJS/test", sbtPublishCommand = "set every credentials := Nil;coreJVM/publishLocal;coreJS/publishLocal", - scalacOptions = SbtCommunityProject.scalacOptions.filter(flag => flag != "-Ysafe-init" && flag != "-Wsafe-init"), + scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Wsafe-init"), dependencies = List(scalacheck) ) @@ -540,7 +540,7 @@ object projects: sbtTestCommand = "set Global/scalaJSStage := FastOptStage;rootJVM/test;rootJS/test", sbtPublishCommand = "rootJVM/publishLocal;rootJS/publishLocal", dependencies = List(discipline, disciplineMunit, scalacheck, simulacrumScalafixAnnotations), - scalacOptions = SbtCommunityProject.scalacOptions.filter(flag => flag != "-Ysafe-init" && flag != "-Wsafe-init") // disable -Ysafe-init or -Wsafe-init, due to -Xfatal-warning + scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Wsafe-init") // disable -Ysafe-init or -Wsafe-init, due to -Xfatal-warning ) lazy val catsMtl = SbtCommunityProject( @@ -655,7 +655,7 @@ object projects: """set actorTests/Compile/scalacOptions -= "-Xfatal-warnings"""", "akka-actor-tests/Test/compile", ).mkString("; "), - scalacOptions = SbtCommunityProject.scalacOptions.filter(flag => flag != "-Ysafe-init" && flag != "-Wsafe-init"), + scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Wsafe-init"), dependencies = List(scalatest, scalatestplusJunit, scalatestplusScalacheck) ) @@ -706,7 +706,7 @@ object projects: project = "fs2", sbtTestCommand = "coreJVM/test; coreJS/test", // io/test requires JDK9+ sbtPublishCommand = "coreJVM/publishLocal; coreJS/publishLocal", - scalacOptions = SbtCommunityProject.scalacOptions.filter(flag => flag != "-Ysafe-init" && flag != "-Wsafe-init"), + scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Wsafe-init"), dependencies = List(cats, catsEffect3, munitCatsEffect, scalacheckEffect, scodecBits) ) @@ -743,7 +743,7 @@ object projects: project = "http4s", sbtTestCommand = """set ThisBuild / tlFatalWarnings := false; rootJVM/test""", sbtPublishCommand = "publishLocal", - scalacOptions = SbtCommunityProject.scalacOptions.filter(flag => flag != "-Ysafe-init" && flag != "-Wsafe-init"), + scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Wsafe-init"), dependencies = List(cats, catsEffect3, fs2, disciplineMunit, scalacheckEffect) ) diff --git a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala index 858c844a6855..5dc7ba821fa6 100644 --- a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala +++ b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala @@ -359,20 +359,8 @@ private sealed trait XSettings: val XmacroSettings: Setting[List[String]] = MultiStringSetting(AdvancedSetting, "Xmacro-settings", "setting1,setting2,..settingN", "List of settings which exposed to the macros") - @deprecated(message = "Superseded by -Wshadow, Scheduled for removal in 3.6.0", since = "3.5.0") - val Xlint: Setting[List[ChoiceWithHelp[String]]] = MultiChoiceHelpSetting( - AdvancedSetting, - name = "Xlint", - helpArg = "advanced warning", - descr = "Enable or disable specific `lint` warnings", - choices = List( - ChoiceWithHelp("all", ""), - ChoiceWithHelp("private-shadow", "Warn if a private field or class parameter shadows a superclass field"), - ChoiceWithHelp("type-parameter-shadow", "Warn when a type parameter shadows a type already in the scope"), - ), - default = Nil, - deprecation = Deprecation.renamed("-Wshadow"), - ) + @deprecated(message = "Superseded by -Wshadow, Scheduled for removal", since = "3.5.0") + val Xlint: Setting[_] = BooleanSetting(AdvancedSetting, "Xlint", "Enable or disable specific warnings", deprecation = Some(Deprecation("Use -Wshadow to enable shadowing lints. Scheduled for removal."))) end XSettings @@ -466,41 +454,41 @@ private sealed trait YSettings: val YinstrumentDefs: Setting[Boolean] = BooleanSetting(ForkSetting, "Yinstrument-defs", "Add instrumentation code that counts method calls; needs -Yinstrument to be set, too.") // Deprecated: lifted from -Y to -X - @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") + @deprecated(message = "Lifted to -X, Scheduled for removal.", since = "3.5.0") val YtermConflict: Setting[String] = ChoiceSetting(ForkSetting, "Yresolve-term-conflict", "strategy", "Resolve term conflicts", List("package", "object", "error"), "error", deprecation = Deprecation.renamed("-Xresolve-term-conflict")) - @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") + @deprecated(message = "Lifted to -X, Scheduled for removal.", since = "3.5.0") val YnoGenericSig: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-generic-signatures", "Suppress generation of generic signatures for Java.", deprecation = Deprecation.renamed("-Xno-generic-signatures")) - @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") + @deprecated(message = "Lifted to -X, Scheduled for removal.", since = "3.5.0") val Ydumpclasses: Setting[String] = StringSetting(ForkSetting, "Ydump-classes", "dir", "Dump the generated bytecode to .class files (useful for reflective compilation that utilizes in-memory classloaders).", default = "", deprecation = Deprecation.renamed("-Xdump-classes")) - @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") + @deprecated(message = "Lifted to -X, Scheduled for removal.", since = "3.5.0") val YjarCompressionLevel: Setting[Int] = IntChoiceSetting(ForkSetting, "Yjar-compression-level", "compression level to use when writing jar files", Deflater.DEFAULT_COMPRESSION to Deflater.BEST_COMPRESSION, Deflater.DEFAULT_COMPRESSION, deprecation = Deprecation.renamed("-Xjar-compression-level")) - @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") + @deprecated(message = "Lifted to -X, Scheduled for removal.", since = "3.5.0") val YkindProjector: Setting[String] = ChoiceSetting(ForkSetting, "Ykind-projector", "[underscores, enable, disable]", "Allow `*` as type lambda placeholder to be compatible with kind projector. When invoked as -Ykind-projector:underscores will repurpose `_` to be a type parameter placeholder, this will disable usage of underscore as a wildcard.", List("disable", "", "underscores"), "disable", legacyArgs = true, deprecation = Deprecation.renamed("-Xkind-projector")) - @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") + @deprecated(message = "Lifted to -X, Scheduled for removal.", since = "3.5.0") val YdropComments: Setting[Boolean] = BooleanSetting(ForkSetting, "Ydrop-docs", "Drop documentation when scanning source files.", aliases = List("-Ydrop-comments"), deprecation = Deprecation.renamed("-Xdrop-docs")) - @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") + @deprecated(message = "Lifted to -X, Scheduled for removal.", since = "3.5.0") val YcookComments: Setting[Boolean] = BooleanSetting(ForkSetting, "Ycook-docs", "Cook the documentation (type check `@usecase`, etc.)", aliases = List("-Ycook-comments"), deprecation = Deprecation.renamed("-Xcook-docs")) - @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") + @deprecated(message = "Lifted to -X, Scheduled for removal.", since = "3.5.0") val YreadComments: Setting[Boolean] = BooleanSetting(ForkSetting, "Yread-docs", "Read documentation from tasty.", deprecation = Deprecation.renamed("-Xread-docs")) - @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") + @deprecated(message = "Lifted to -X, Scheduled for removal.", since = "3.5.0") val YnoDecodeStacktraces: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-decode-stacktraces", "Show raw StackOverflow stacktraces, instead of decoding them into triggering operations.", deprecation = Deprecation.renamed("-Xno-decode-stacktraces")) - @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") + @deprecated(message = "Lifted to -X, Scheduled for removal.", since = "3.5.0") val YnoEnrichErrorMessages: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-enrich-error-messages", "Show raw error messages, instead of enriching them with contextual information.", deprecation = Deprecation.renamed("-Xno-enrich-error-messages")) - @deprecated(message = "Lifted to -X, Scheduled for removal in 3.6.0", since = "3.5.0") + @deprecated(message = "Lifted to -X, Scheduled for removal.", since = "3.5.0") val YdebugMacros: Setting[Boolean] = BooleanSetting(ForkSetting, "Ydebug-macros", "Show debug info when quote pattern match fails", deprecation = Deprecation.renamed("-Xdebug-macros")) - // @deprecated(message = "Lifted to -X, Scheduled for removal in 3.8.0", since = "3.7.0") + // @deprecated(message = "Lifted to -X, Scheduled for removal.", since = "3.7.0") // val YjavaTasty: Setting[Boolean] = BooleanSetting(ForkSetting, "Yjava-tasty", "Pickler phase should compute TASTy for .java defined symbols for use by build tools", aliases = List("-Ypickle-java"), preferPrevious = true, deprecation = Deprecation.lifted("-Xjava-tasty")) - // @deprecated(message = "Lifted to -X, Scheduled for removal in 3.8.0", since = "3.7.0") + // @deprecated(message = "Lifted to -X, Scheduled for removal.", since = "3.7.0") // val YearlyTastyOutput: Setting[AbstractFile] = OutputSetting(ForkSetting, "Yearly-tasty-output", "directory|jar", "Destination to write generated .tasty files to for use in pipelined compilation.", NoAbstractFile, aliases = List("-Ypickle-write"), preferPrevious = true, deprecation = Deprecation.lifted("-Xearly-tasty-output")) - // @deprecated(message = "Lifted to -X, Scheduled for removal in 3.8.0", since = "3.7.0") + // @deprecated(message = "Lifted to -X, Scheduled for removal.", since = "3.7.0") // val YallowOutlineFromTasty: Setting[Boolean] = BooleanSetting(ForkSetting, "Yallow-outline-from-tasty", "Allow outline TASTy to be loaded with the -from-tasty option.", deprecation = Deprecation.lifted("-Xallow-outline-from-tasty")) // Deprecated: lifted from -Y to -W - @deprecated(message = "Lifted to -W, Scheduled for removal in 3.6.0", since = "3.5.0") + @deprecated(message = "Lifted to -W, Scheduled for removal.", since = "3.5.0") val YcheckInit: Setting[Boolean] = BooleanSetting(ForkSetting, "Ysafe-init", "Ensure safe initialization of objects.", deprecation = Deprecation.renamed("-Wsafe-init")) // Deprecated: Scheduled for removal - @deprecated(message = "Scheduled for removal in 3.6.0", since = "3.5.0") - val YoutputOnlyTasty: Setting[Boolean] = BooleanSetting(ForkSetting, "Youtput-only-tasty", "Used to only generate the TASTy file without the classfiles", deprecation = Deprecation.removed("3.6.0")) + @deprecated(message = "Scheduled for removal.", since = "3.5.0") + val YoutputOnlyTasty: Setting[Boolean] = BooleanSetting(ForkSetting, "Youtput-only-tasty", "Used to only generate the TASTy file without the classfiles", deprecation = Deprecation.removed()) end YSettings diff --git a/compiler/src/dotty/tools/dotc/config/Settings.scala b/compiler/src/dotty/tools/dotc/config/Settings.scala index a3b7c50d7d1f..786268f841a8 100644 --- a/compiler/src/dotty/tools/dotc/config/Settings.scala +++ b/compiler/src/dotty/tools/dotc/config/Settings.scala @@ -134,7 +134,9 @@ object Settings: if argStringValue.isEmpty then state.deprecated(deprecatedMsg, List(replacedBy)) else state.deprecated(deprecatedMsg, List(s"$replacedBy:$argStringValue")) - case Some(Deprecation(msg, _)) => state.deprecated(msg) + case Some(Deprecation(msg, _)) => + state.deprecated(s"Option $name is deprecated: $msg") + case None => val value = getValue var dangers = warnings @@ -263,14 +265,16 @@ object Settings: * @param msg deprecation message that will be displayed in following format: s"Option $name is deprecated: $msg" * @param replacedBy option that is substituting current option */ - case class Deprecation private( + case class Deprecation( msg: String, replacedBy: Option[String] = None, ) object Deprecation: def renamed(replacement: String) = Some(Deprecation(s"Use $replacement instead.", Some(replacement))) - def removed(removedVersion: String) = Some(Deprecation(s"Scheduled for removal in s$removedVersion", None)) + def removed(removedVersion: Option[String] = None) = + val msg = removedVersion.map(" in " + _).getOrElse(".") + Some(Deprecation(s"Scheduled for removal$msg", None)) object Setting: extension [T](setting: Setting[T]) diff --git a/compiler/test/dotty/tools/dotc/config/ScalaSettingsTests.scala b/compiler/test/dotty/tools/dotc/config/ScalaSettingsTests.scala index 9ebde841c50b..28dd5e307bc5 100644 --- a/compiler/test/dotty/tools/dotc/config/ScalaSettingsTests.scala +++ b/compiler/test/dotty/tools/dotc/config/ScalaSettingsTests.scala @@ -112,7 +112,7 @@ class ScalaSettingsTests: // createTestCase(settings.YearlyTastyOutput , settings.XearlyTastyOutput, ":./"), // createTestCase(settings.YallowOutlineFromTasty, settings.XallowOutlineFromTasty), createTestCase(settings.YcheckInit , settings.WcheckInit), - createTestCase(settings.Xlint , settings.Wshadow, ":all"), + // createTestCase(settings.Xlint , settings.Wshadow, ":all"), // this setting is not going to be mapped to replacement. Read more in the commit message ).map: (deprecatedArgument, newSetting) => val args = List(deprecatedArgument) val argSummary = ArgsSummary(settings.defaultState, args, errors = Nil, warnings = Nil) @@ -171,7 +171,7 @@ class ScalaSettingsTests: // createTestCase(settings.YearlyTastyOutput , settings.XearlyTastyOutput, ":./"), // createTestCase(settings.YallowOutlineFromTasty, settings.XallowOutlineFromTasty), createTestCase(settings.YcheckInit , settings.WcheckInit), - createTestCase(settings.Xlint , settings.Wshadow, ":all"), + // createTestCase(settings.Xlint , settings.Wshadow, ":all"), // this setting is not going to be mapped to replacement. Read more in the commit message ).flatten.map: (deprecatedArgument, newSetting) => val args = List(deprecatedArgument) val argSummary = ArgsSummary(settings.defaultState, args, errors = Nil, warnings = Nil) From 44d593da1b14ddb1e2fd68901ae8062fbb2f6f38 Mon Sep 17 00:00:00 2001 From: rochala Date: Tue, 7 May 2024 02:01:58 +0200 Subject: [PATCH 17/19] Remove extra check for -Ysafe-init --- community-build/src/scala/dotty/communitybuild/projects.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/community-build/src/scala/dotty/communitybuild/projects.scala b/community-build/src/scala/dotty/communitybuild/projects.scala index ca51db338c84..a0444505801a 100644 --- a/community-build/src/scala/dotty/communitybuild/projects.scala +++ b/community-build/src/scala/dotty/communitybuild/projects.scala @@ -526,7 +526,7 @@ object projects: sbtTestCommand = "test", sbtPublishCommand = "coreJVM/publishLocal;coreJS/publishLocal", dependencies = List(discipline), - scalacOptions = SbtCommunityProject.scalacOptions.filter(flag => flag != "-Ysafe-init" && flag != "-Wsafe-init") + scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Wsafe-init") ) lazy val simulacrumScalafixAnnotations = SbtCommunityProject( From df8e8ba3a669d86effd637d44ca2eeaece5bde74 Mon Sep 17 00:00:00 2001 From: rochala Date: Tue, 7 May 2024 09:11:57 +0200 Subject: [PATCH 18/19] Properly revert old behaviour of Xlint --- .../src/dotty/tools/dotc/config/ScalaSettings.scala | 2 +- compiler/src/dotty/tools/dotc/config/Settings.scala | 10 +++++++--- .../dotty/tools/dotc/config/ScalaSettingsTests.scala | 11 +++++++++++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala index 5dc7ba821fa6..86b657ddf00d 100644 --- a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala +++ b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala @@ -360,7 +360,7 @@ private sealed trait XSettings: val XmacroSettings: Setting[List[String]] = MultiStringSetting(AdvancedSetting, "Xmacro-settings", "setting1,setting2,..settingN", "List of settings which exposed to the macros") @deprecated(message = "Superseded by -Wshadow, Scheduled for removal", since = "3.5.0") - val Xlint: Setting[_] = BooleanSetting(AdvancedSetting, "Xlint", "Enable or disable specific warnings", deprecation = Some(Deprecation("Use -Wshadow to enable shadowing lints. Scheduled for removal."))) + val Xlint: Setting[_] = BooleanSetting(AdvancedSetting, "Xlint", "Enable or disable specific warnings", deprecation = Some(Deprecation("Use -Wshadow to enable shadowing lints. Scheduled for removal.")), ignoreInvalidArgs = true) end XSettings diff --git a/compiler/src/dotty/tools/dotc/config/Settings.scala b/compiler/src/dotty/tools/dotc/config/Settings.scala index 786268f841a8..1e2ced4d65a7 100644 --- a/compiler/src/dotty/tools/dotc/config/Settings.scala +++ b/compiler/src/dotty/tools/dotc/config/Settings.scala @@ -251,7 +251,11 @@ object Settings: def argValRest: String = if(prefix.isEmpty) arg.dropWhile(_ != ':').drop(1) else arg.drop(prefix.get.length) - if matches(arg) then doSet(argValRest) + if matches(arg) then + deprecation match + case Some(Deprecation(msg, _)) if ignoreInvalidArgs => // a special case for Xlint + state.deprecated(s"Option $name is deprecated: $msg") + case _ => doSet(argValRest) else state end tryToSet @@ -367,8 +371,8 @@ object Settings: assert(!name.startsWith("-"), s"Setting $name cannot start with -") "-" + name - def BooleanSetting(category: SettingCategory, name: String, descr: String, initialValue: Boolean = false, aliases: List[String] = Nil, preferPrevious: Boolean = false, deprecation: Option[Deprecation] = None): Setting[Boolean] = - publish(Setting(category, prependName(name), descr, initialValue, aliases = aliases, preferPrevious = preferPrevious, deprecation = deprecation)) + def BooleanSetting(category: SettingCategory, name: String, descr: String, initialValue: Boolean = false, aliases: List[String] = Nil, preferPrevious: Boolean = false, deprecation: Option[Deprecation] = None, ignoreInvalidArgs: Boolean = false): Setting[Boolean] = + publish(Setting(category, prependName(name), descr, initialValue, aliases = aliases, preferPrevious = preferPrevious, deprecation = deprecation, ignoreInvalidArgs = ignoreInvalidArgs)) def StringSetting(category: SettingCategory, name: String, helpArg: String, descr: String, default: String, aliases: List[String] = Nil, deprecation: Option[Deprecation] = None): Setting[String] = publish(Setting(category, prependName(name), descr, default, helpArg, aliases = aliases, deprecation = deprecation)) diff --git a/compiler/test/dotty/tools/dotc/config/ScalaSettingsTests.scala b/compiler/test/dotty/tools/dotc/config/ScalaSettingsTests.scala index 28dd5e307bc5..3dc4f4e4ec5e 100644 --- a/compiler/test/dotty/tools/dotc/config/ScalaSettingsTests.scala +++ b/compiler/test/dotty/tools/dotc/config/ScalaSettingsTests.scala @@ -148,6 +148,17 @@ class ScalaSettingsTests: val conf = settings.processArguments(argSummary, processAll = true, skipped = Nil) assert(newSetting.isDefaultIn(conf.sstate), s"Setting $deprecatedArgument was forwarded to ${newSetting.name}, when it should be ignored because first option was erroreus") + // -Xlint was handled in a special way when it was added, making in hard to deprecate it. + // For now on we will retain old behavior, in next version we will emit deprecation warning. + // It is also scheduled for removal in future versions. + @Test def `Make Xlint to ignore invalid args`: Unit = + val settings = ScalaSettings + val args = List("-Xlint:-unused,_") + val argSummary = ArgsSummary(settings.defaultState, args, errors = Nil, warnings = Nil) + val conf = settings.processArguments(argSummary, processAll = true, skipped = Nil) + assert(conf.warnings.contains("Option -Xlint is deprecated: Use -Wshadow to enable shadowing lints. Scheduled for removal.")) + assert(conf.errors.isEmpty) + @nowarn("cat=deprecation") @Test def `Deprecated options aliases are correctly mapped to their replacements`: Unit = def createTestCase(oldSetting: Setting[_], newSetting: Setting[_], value: String = "") = From c708515408a420a90b44cc698e6b7f365953ee8d Mon Sep 17 00:00:00 2001 From: rochala Date: Tue, 7 May 2024 10:44:44 +0200 Subject: [PATCH 19/19] Fix wrong submodule hash after rebase --- community-build/community-projects/shapeless-3 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/community-build/community-projects/shapeless-3 b/community-build/community-projects/shapeless-3 index 90f0c977b536..24e86dd290eb 160000 --- a/community-build/community-projects/shapeless-3 +++ b/community-build/community-projects/shapeless-3 @@ -1 +1 @@ -Subproject commit 90f0c977b536c06305496600b8b2014c9e8e3d86 +Subproject commit 24e86dd290eba9b27599936a7f338fac975f833d