Skip to content

Commit

Permalink
Handle -Ykind-projector as legacy option
Browse files Browse the repository at this point in the history
  • Loading branch information
szymon-rd committed Mar 6, 2024
1 parent 018dc17 commit 04c0976
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/config/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ private sealed trait YSettings:
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", "enable", "underscores"), "disable")
val YkindProjector: Setting[String] = LegacyChoiceSetting(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")
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.")
Expand Down
10 changes: 8 additions & 2 deletions compiler/src/dotty/tools/dotc/config/Settings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ object Settings:
depends: List[(Setting[?], Any)] = Nil,
ignoreInvalidArgs: Boolean = false,
propertyClass: Option[Class[?]] = None,
deprecationMsg: Option[String] = None)(private[Settings] val idx: Int) {
deprecationMsg: Option[String] = None,
// kept only for -Ykind-projector option compatibility
legacyArgs: Boolean = false)(private[Settings] val idx: Int) {


assert(name.startsWith(s"-$category"), s"Setting $name does not start with category -$category")
Expand Down Expand Up @@ -188,7 +190,7 @@ object Settings:
case (OptionTag, _) =>
update(Some(propertyClass.get.getConstructor().newInstance()), args)
case (ct, args) =>
val argInArgRest = !argRest.isEmpty
val argInArgRest = !argRest.isEmpty || (legacyArgs && choices.exists(_.contains("")))
val argAfterParam = !argInArgRest && args.nonEmpty && (ct == IntTag || !args.head.startsWith("-"))
if argInArgRest then
doSetArg(argRest, args)
Expand Down Expand Up @@ -336,6 +338,10 @@ object Settings:
def ChoiceSetting(category: String, name: String, helpArg: String, descr: String, choices: List[String], default: String, aliases: List[String] = Nil): Setting[String] =
publish(Setting(category, validateAndPrependName(name), descr, default, helpArg, Some(choices), aliases = aliases.map(validateSetting)))

// Allows only args after :, but supports empty string as a choice. Used for -Ykind-projector
def LegacyChoiceSetting(category: String, name: String, helpArg: String, descr: String, choices: List[String], default: String, aliases: List[String] = Nil): Setting[String] =
publish(Setting(category, validateAndPrependName(name), descr, default, helpArg, Some(choices), aliases = aliases.map(validateSetting), legacyArgs = true))

def MultiChoiceSetting(category: String, name: String, helpArg: String, descr: String, choices: List[String], default: List[String], aliases: List[String] = Nil): Setting[List[String]] =
publish(Setting(category, validateAndPrependName(name), descr, default, helpArg, Some(choices), aliases = aliases.map(validateSetting)))

Expand Down
2 changes: 1 addition & 1 deletion tests/neg/kind-projector.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Ykind-projector:enable
//> using options -Ykind-projector

package kind_projector_neg

Expand Down
2 changes: 1 addition & 1 deletion tests/pos/kind-projector.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Ykind-projector:enable
//> using options -Ykind-projector

package kind_projector

Expand Down

0 comments on commit 04c0976

Please sign in to comment.