Skip to content

Commit de7bd5b

Browse files
committed
Multivalue with default means colon is required
1 parent 4ea39aa commit de7bd5b

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

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

+1-4
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ trait CommonScalaSettings:
114114
val explainTypes: Setting[Boolean] = BooleanSetting(RootSetting, "explain-types", "Explain type errors in more detail (deprecated, use -explain instead).", aliases = List("--explain-types", "-explaintypes"))
115115
val explainCyclic: Setting[Boolean] = BooleanSetting(RootSetting, "explain-cyclic", "Explain cyclic reference errors in more detail.", aliases = List("--explain-cyclic"))
116116
val unchecked: Setting[Boolean] = BooleanSetting(RootSetting, "unchecked", "Enable additional warnings where generated code depends on assumptions.", initialValue = true, aliases = List("--unchecked"))
117-
val language: Setting[List[ChoiceWithHelp[String]]] = MultiChoiceHelpSetting(RootSetting, "language", "feature", "Enable one or more language features.", choices = ScalaSettingsProperties.supportedLanguageFeatures, legacyChoices = ScalaSettingsProperties.legacyLanguageFeatures, default = Nil, aliases = List("--language"))
117+
val language: Setting[List[ChoiceWithHelp[String]]] = MultiChoiceHelpSetting(RootSetting, "language", "feature", "Enable one or more language features.", choices = ScalaSettingsProperties.supportedLanguageFeatures, legacyChoices = ScalaSettingsProperties.legacyLanguageFeatures, aliases = List("--language"))
118118
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.")
119119
val preview: Setting[Boolean] = BooleanSetting(RootSetting, "preview", "Enable the use of preview features anywhere in the project.")
120120

@@ -191,7 +191,6 @@ private sealed trait WarningSettings:
191191
),
192192
ChoiceWithHelp("unsafe-warn-patvars", "Deprecated alias for `patvars`"),
193193
),
194-
default = Nil
195194
)
196195
object WunusedHas:
197196
def isChoiceSet(s: String)(using Context) = Wunused.value.pipe(us => us.contains(s))
@@ -225,7 +224,6 @@ private sealed trait WarningSettings:
225224
WarningSetting,
226225
"Wconf",
227226
"patterns",
228-
default = List(),
229227
descr =
230228
raw"""Configure compiler warnings.
231229
|Syntax: -Wconf:<filters>:<action>,<filters>:<action>,...
@@ -287,7 +285,6 @@ private sealed trait WarningSettings:
287285
ChoiceWithHelp("private-shadow", "Warn if a private field or class parameter shadows a superclass field"),
288286
ChoiceWithHelp("type-parameter-shadow", "Warn when a type parameter shadows a type already in the scope"),
289287
),
290-
default = Nil
291288
)
292289

293290
object WshadowHas:

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

+4-5
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ object Settings:
124124

125125
def isMultivalue: Boolean = classTag[T] == ListTag
126126

127-
def acceptsNoArg: Boolean = classTag[T] == BooleanTag || classTag[T] == OptionTag || choices.exists(_.contains(""))
128-
129127
def legalChoices: String =
130128
choices match
131129
case Some(xs) if xs.isEmpty => ""
@@ -248,10 +246,11 @@ object Settings:
248246
update(Some(propertyClass.get.getConstructor().newInstance()), "", args)
249247
case ct =>
250248
val argInArgRest = !argRest.isEmpty || legacyArgs
251-
inline def argAfterParam = !argInArgRest && args.nonEmpty && (ct == IntTag || !args.head.startsWith("-"))
249+
inline def argAfterParam = args.nonEmpty && (ct == IntTag || !args.head.startsWith("-"))
250+
inline def isMultivalueWithDefault = isMultivalue && !isEmptyDefault
252251
if argInArgRest then
253252
doSetArg(argRest, args)
254-
else if argAfterParam then
253+
else if argAfterParam && !isMultivalueWithDefault then
255254
doSetArg(args.head, args.tail)
256255
else if isEmptyDefault then
257256
missingArg
@@ -420,7 +419,7 @@ object Settings:
420419
def MultiChoiceSetting(category: SettingCategory, name: String, helpArg: String, descr: String, choices: List[String], default: List[String] = Nil, legacyChoices: List[String] = Nil, aliases: List[String] = Nil, deprecation: Option[Deprecation] = None): Setting[List[String]] =
421420
publish(Setting(category, prependName(name), descr, default, helpArg, Some(choices), legacyChoices = Some(legacyChoices), aliases = aliases, deprecation = deprecation))
422421

423-
def MultiChoiceHelpSetting(category: SettingCategory, name: String, helpArg: String, descr: String, choices: List[ChoiceWithHelp[String]], default: List[ChoiceWithHelp[String]], legacyChoices: List[String] = Nil, aliases: List[String] = Nil, deprecation: Option[Deprecation] = None): Setting[List[ChoiceWithHelp[String]]] =
422+
def MultiChoiceHelpSetting(category: SettingCategory, name: String, helpArg: String, descr: String, choices: List[ChoiceWithHelp[String]], default: List[ChoiceWithHelp[String]] = Nil, legacyChoices: List[String] = Nil, aliases: List[String] = Nil, deprecation: Option[Deprecation] = None): Setting[List[ChoiceWithHelp[String]]] =
424423
publish(Setting(category, prependName(name), descr, default, helpArg, Some(choices), legacyChoices = Some(legacyChoices), aliases = aliases, deprecation = deprecation))
425424

426425
def IntSetting(category: SettingCategory, name: String, descr: String, default: Int, aliases: List[String] = Nil, deprecation: Option[Deprecation] = None): Setting[Int] =

0 commit comments

Comments
 (0)