diff --git a/community-build/community-projects/Monocle b/community-build/community-projects/Monocle index a0e70744e9b3..a9a12a13a48c 160000 --- a/community-build/community-projects/Monocle +++ b/community-build/community-projects/Monocle @@ -1 +1 @@ -Subproject commit a0e70744e9b3bfb0f12e4ea292151c49c3302cd1 +Subproject commit a9a12a13a48c957535ddd6850ed8c6b0db2dc4fe diff --git a/community-build/community-projects/akka b/community-build/community-projects/akka index 79b294048f89..2dffb6504005 160000 --- a/community-build/community-projects/akka +++ b/community-build/community-projects/akka @@ -1 +1 @@ -Subproject commit 79b294048f893d9d6b9332618f7aebedce9a5340 +Subproject commit 2dffb6504005a6144561c4e3ba7b185639a8ad48 diff --git a/community-build/community-projects/endpoints4s b/community-build/community-projects/endpoints4s index 3a667a3608ff..cc03ddf1c4a0 160000 --- a/community-build/community-projects/endpoints4s +++ b/community-build/community-projects/endpoints4s @@ -1 +1 @@ -Subproject commit 3a667a3608ff9950c24e9b2b5038c71c1690a21d +Subproject commit cc03ddf1c4a03391c8031784e48c057bdc9394db diff --git a/community-build/community-projects/izumi-reflect b/community-build/community-projects/izumi-reflect index c0756faa7311..bd4ae213f81e 160000 --- a/community-build/community-projects/izumi-reflect +++ b/community-build/community-projects/izumi-reflect @@ -1 +1 @@ -Subproject commit c0756faa7311f70c6da6af29b8cb25506634bf09 +Subproject commit bd4ae213f81e63c330b22cf5f73f68641814b195 diff --git a/community-build/community-projects/parboiled2 b/community-build/community-projects/parboiled2 index 628127744bde..3fb32f833f8c 160000 --- a/community-build/community-projects/parboiled2 +++ b/community-build/community-projects/parboiled2 @@ -1 +1 @@ -Subproject commit 628127744bde8dc2e01432badd68886a5f722f71 +Subproject commit 3fb32f833f8c6a2fca25474c189efd91ffb65557 diff --git a/community-build/community-projects/scala-collection-compat b/community-build/community-projects/scala-collection-compat index b39b4b64732d..2bf3fea914b2 160000 --- a/community-build/community-projects/scala-collection-compat +++ b/community-build/community-projects/scala-collection-compat @@ -1 +1 @@ -Subproject commit b39b4b64732d9dd5e0f065e4180f656237ac4444 +Subproject commit 2bf3fea914b2f13e4805b3e7b519bdf0e595e4c9 diff --git a/community-build/community-projects/scala-xml b/community-build/community-projects/scala-xml index 105c3dac8835..0605c07e298c 160000 --- a/community-build/community-projects/scala-xml +++ b/community-build/community-projects/scala-xml @@ -1 +1 @@ -Subproject commit 105c3dac883549eca1182b04fc5a18fe4f5ad51a +Subproject commit 0605c07e298c1bd8758f79d3c790f89db986a6bc diff --git a/community-build/community-projects/scalaz b/community-build/community-projects/scalaz index 97cccf3b3fcb..4919bdce732f 160000 --- a/community-build/community-projects/scalaz +++ b/community-build/community-projects/scalaz @@ -1 +1 @@ -Subproject commit 97cccf3b3fcb71885a32b2e567171c0f70b06104 +Subproject commit 4919bdce732f53a3316d5e12d9c853fc2141ddfb diff --git a/compiler/src/dotty/tools/dotc/config/CliCommand.scala b/compiler/src/dotty/tools/dotc/config/CliCommand.scala index 5ac6b772df95..b0046ee49cd1 100644 --- a/compiler/src/dotty/tools/dotc/config/CliCommand.scala +++ b/compiler/src/dotty/tools/dotc/config/CliCommand.scala @@ -53,7 +53,7 @@ trait CliCommand: end distill /** Creates a help message for a subset of options based on cond */ - protected def availableOptionsMsg(p: Setting[?] => Boolean)(using settings: ConcreteSettings)(using SettingsState): String = + protected def availableOptionsMsg(p: Setting[?] => Boolean, showArgFileMsg: Boolean = true)(using settings: ConcreteSettings)(using SettingsState): String = // result is (Option Name, descrption\ndefault: value\nchoices: x, y, z def help(s: Setting[?]): (String, String) = // For now, skip the default values that do not make sense for the end user, such as 'false' for the version command. @@ -68,7 +68,10 @@ trait CliCommand: val ss = settings.allSettings.filter(p).toList.sortBy(_.name) val formatter = Columnator("", "", maxField = 30) val fresh = ContextBase().initialCtx.fresh.setSettings(summon[SettingsState]) - formatter(List(ss.map(help) :+ ("@", "A text file containing compiler arguments (options and source files).")))(using fresh) + var msg = ss.map(help) + if showArgFileMsg then + msg = msg :+ ("@", "A text file containing compiler arguments (options and source files).") + formatter(List(msg))(using fresh) end availableOptionsMsg protected def shortUsage: String = s"Usage: $cmdName " diff --git a/compiler/src/dotty/tools/dotc/config/CompilerCommand.scala b/compiler/src/dotty/tools/dotc/config/CompilerCommand.scala index 587f94dad7b3..43f3ed63f969 100644 --- a/compiler/src/dotty/tools/dotc/config/CompilerCommand.scala +++ b/compiler/src/dotty/tools/dotc/config/CompilerCommand.scala @@ -9,7 +9,7 @@ abstract class CompilerCommand extends CliCommand: final def helpMsg(using settings: ConcreteSettings)(using SettingsState, Context): String = settings.allSettings.find(isHelping) match - case Some(s) => s.description + case Some(s) => availableOptionsMsg(_ == s, showArgFileMsg = false) case _ => if (settings.help.value) usageMessage else if (settings.Vhelp.value) vusageMessage diff --git a/compiler/src/dotty/tools/dotc/config/Feature.scala b/compiler/src/dotty/tools/dotc/config/Feature.scala index 0d551094da4d..91100627981b 100644 --- a/compiler/src/dotty/tools/dotc/config/Feature.scala +++ b/compiler/src/dotty/tools/dotc/config/Feature.scala @@ -11,6 +11,7 @@ import SourceVersion.* import reporting.Message import NameKinds.QualifiedName import Annotations.ExperimentalAnnotation +import Settings.Setting.ChoiceWithHelp object Feature: @@ -42,6 +43,35 @@ object Feature: .map(sym => experimental(sym.name)) .filterNot(_ == captureChecking) // TODO is this correct? + val values = List( + (nme.help, "Display all available features"), + (nme.noAutoTupling, "Disable automatic tupling"), + (nme.dynamics, "Allow direct or indirect subclasses of scala.Dynamic"), + (nme.unsafeNulls, "Enable unsafe nulls for explicit nulls"), + (nme.postfixOps, "Allow postfix operators (not recommended)"), + (nme.strictEquality, "Enable strict equality (disable canEqualAny)"), + (nme.implicitConversions, "Allow implicit conversions without warnings"), + (nme.adhocExtensions, "Allow ad-hoc extension methods"), + (namedTypeArguments, "Allow named type arguments"), + (genericNumberLiterals, "Allow generic number literals"), + (scala2macros, "Allow Scala 2 macros"), + (dependent, "Allow dependent method types"), + (erasedDefinitions, "Allow erased definitions"), + (symbolLiterals, "Allow symbol literals"), + (fewerBraces, "Enable support for using indentation for arguments"), + (saferExceptions, "Enable safer exceptions"), + (clauseInterleaving, "Enable clause interleaving"), + (pureFunctions, "Enable pure functions for capture checking"), + (captureChecking, "Enable experimental capture checking"), + (into, "Allow into modifier on parameter types"), + (namedTuples, "Allow named tuples"), + (modularity, "Enable experimental modularity features"), + (betterMatchTypeExtractors, "Enable better match type extractors") + ) + + private def enabledLanguageFeaturesBySetting(using Context): List[String] = + ctx.settings.language.value.asInstanceOf + /** Is `feature` enabled by by a command-line setting? The enabling setting is * * -language:feature @@ -50,7 +80,7 @@ object Feature: * but subtracting the prefix `scala.language.` at the front. */ def enabledBySetting(feature: TermName)(using Context): Boolean = - ctx.base.settings.language.value.contains(feature.toString) + enabledLanguageFeaturesBySetting.contains(feature.toString) /** Is `feature` enabled by by an import? This is the case if the feature * is imported by a named import diff --git a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala index 86b657ddf00d..bb28e06150fe 100644 --- a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala +++ b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala @@ -114,7 +114,7 @@ trait CommonScalaSettings: val explainTypes: Setting[Boolean] = BooleanSetting(RootSetting, "explain-types", "Explain type errors in more detail (deprecated, use -explain instead).", aliases = List("--explain-types", "-explaintypes")) val explainCyclic: Setting[Boolean] = BooleanSetting(RootSetting, "explain-cyclic", "Explain cyclic reference errors in more detail.", aliases = List("--explain-cyclic")) val unchecked: Setting[Boolean] = BooleanSetting(RootSetting, "unchecked", "Enable additional warnings where generated code depends on assumptions.", initialValue = true, aliases = List("--unchecked")) - val language: Setting[List[String]] = MultiStringSetting(RootSetting, "language", "feature", "Enable one or more language features.", aliases = List("--language")) + val language: Setting[List[ChoiceWithHelp[String]]] = MultiChoiceHelpSetting(RootSetting, "language", "feature", "Enable one or more language features.", choices = ScalaSettingsProperties.supportedLanguageFeatures, default = Nil, aliases = List("--language")) val experimental: Setting[Boolean] = BooleanSetting(RootSetting, "experimental", "Annotate all top-level definitions with @experimental. This enables the use of experimental features anywhere in the project.") /* Coverage settings */ @@ -492,3 +492,4 @@ private sealed trait YSettings: @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/ScalaSettingsProperties.scala b/compiler/src/dotty/tools/dotc/config/ScalaSettingsProperties.scala index e8a55dc6e737..a839d3e3be19 100644 --- a/compiler/src/dotty/tools/dotc/config/ScalaSettingsProperties.scala +++ b/compiler/src/dotty/tools/dotc/config/ScalaSettingsProperties.scala @@ -1,6 +1,7 @@ package dotty.tools.dotc package config +import Settings.Setting.ChoiceWithHelp import dotty.tools.backend.jvm.BackendUtils.classfileVersionMap import dotty.tools.io.{AbstractFile, Directory, JDK9Reflectors, PlainDirectory, NoAbstractFile} import scala.language.unsafeNulls @@ -26,6 +27,9 @@ object ScalaSettingsProperties: def supportedSourceVersions: List[String] = SourceVersion.values.toList.map(_.toString) + def supportedLanguageFeatures: List[ChoiceWithHelp[String]] = + Feature.values.map((n, d) => ChoiceWithHelp(n.toString, d)) + def defaultClasspath: String = sys.env.getOrElse("CLASSPATH", ".") def defaultPageWidth: Int = { diff --git a/compiler/src/dotty/tools/dotc/config/Settings.scala b/compiler/src/dotty/tools/dotc/config/Settings.scala index 1e2ced4d65a7..5042737c30cb 100644 --- a/compiler/src/dotty/tools/dotc/config/Settings.scala +++ b/compiler/src/dotty/tools/dotc/config/Settings.scala @@ -380,7 +380,7 @@ object Settings: 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, deprecation: Option[Deprecation] = None): Setting[List[String]] = + def MultiChoiceSetting(category: SettingCategory, name: String, helpArg: String, descr: String, choices: List[String], default: List[String] = Nil, 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, deprecation: Option[Deprecation] = None): Setting[List[ChoiceWithHelp[String]]] = diff --git a/compiler/src/dotty/tools/dotc/core/StdNames.scala b/compiler/src/dotty/tools/dotc/core/StdNames.scala index b935488695e0..3753d1688399 100644 --- a/compiler/src/dotty/tools/dotc/core/StdNames.scala +++ b/compiler/src/dotty/tools/dotc/core/StdNames.scala @@ -509,6 +509,7 @@ object StdNames { val _hashCode_ : N = "_hashCode" val hash_ : N = "hash" val head: N = "head" + val help: N = "help" val higherKinds: N = "higherKinds" val idx: N = "idx" val identity: N = "identity" diff --git a/compiler/test/dotty/tools/DottyTest.scala b/compiler/test/dotty/tools/DottyTest.scala index 7ccbc09a4c92..2b94801b67d7 100644 --- a/compiler/test/dotty/tools/DottyTest.scala +++ b/compiler/test/dotty/tools/DottyTest.scala @@ -40,7 +40,7 @@ trait DottyTest extends ContextEscapeDetection { protected def initializeCtx(fc: FreshContext): Unit = { fc.setSetting(fc.settings.encoding, "UTF8") fc.setSetting(fc.settings.classpath, TestConfiguration.basicClasspath) - fc.setSetting(fc.settings.language, List("experimental.erasedDefinitions")) + fc.setSetting(fc.settings.language, List("experimental.erasedDefinitions").asInstanceOf) fc.setProperty(ContextDoc, new ContextDocstrings) } diff --git a/compiler/test/dotty/tools/dotc/CompilationTests.scala b/compiler/test/dotty/tools/dotc/CompilationTests.scala index de3bd02bba6e..2b9ebd2c69d1 100644 --- a/compiler/test/dotty/tools/dotc/CompilationTests.scala +++ b/compiler/test/dotty/tools/dotc/CompilationTests.scala @@ -143,7 +143,7 @@ class CompilationTests { "tests/neg-custom-args/toplevel-samesource/S.scala", "tests/neg-custom-args/toplevel-samesource/nested/S.scala"), defaultOptions), - compileFile("tests/neg/i7575.scala", defaultOptions.withoutLanguageFeatures.and("-language:_")), + compileFile("tests/neg/i7575.scala", defaultOptions.withoutLanguageFeatures), ).checkExpectedErrors() }