Skip to content

Commit 9f469ed

Browse files
committed
Handle -Ykind-projector as legacy option
1 parent 820fc63 commit 9f469ed

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ private sealed trait YSettings:
400400
val YstopBefore: Setting[List[String]] = PhasesSetting(ForkSetting, "Ystop-before", "Stop before") // stop before erasure as long as we have not debugged it fully
401401
val YshowSuppressedErrors: Setting[Boolean] = BooleanSetting(ForkSetting, "Yshow-suppressed-errors", "Also show follow-on errors and warnings that are normally suppressed.")
402402
val YdetailedStats: Setting[Boolean] = BooleanSetting(ForkSetting, "Ydetailed-stats", "Show detailed internal compiler stats (needs Stats.enabled to be set to true).")
403-
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")
403+
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")
404404
val YprintPos: Setting[Boolean] = BooleanSetting(ForkSetting, "Yprint-pos", "Show tree positions.")
405405
val YprintPosSyms: Setting[Boolean] = BooleanSetting(ForkSetting, "Yprint-pos-syms", "Show symbol definitions positions.")
406406
val YnoDeepSubtypes: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-deep-subtypes", "Throw an exception on deep subtyping call stacks.")

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

+8-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ object Settings:
7171
depends: List[(Setting[?], Any)] = Nil,
7272
ignoreInvalidArgs: Boolean = false,
7373
propertyClass: Option[Class[?]] = None,
74-
deprecationMsg: Option[String] = None)(private[Settings] val idx: Int) {
74+
deprecationMsg: Option[String] = None,
75+
// kept only for -Ykind-projector option compatibility
76+
legacyArgs: Boolean = false)(private[Settings] val idx: Int) {
7577

7678

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

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

compiler/test/dotty/tools/dotc/TastyBootstrapTests.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class TastyBootstrapTests {
5151
Properties.compilerInterface, Properties.scalaLibrary, Properties.scalaAsm,
5252
Properties.dottyInterfaces, Properties.jlineTerminal, Properties.jlineReader,
5353
).mkString(File.pathSeparator),
54-
Array("-Ycheck-reentrant", "-Ylog:checkReentrant+", "-language:postfixOps", "-Xsemanticdb")
54+
Array("-Ycheck-reentrant", "-language:postfixOps", "-Xsemanticdb")
5555
)
5656

5757
val libraryDirs = List(Paths.get("library/src"), Paths.get("library/src-bootstrapped"))

tests/neg/kind-projector.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//> using options -Ykind-projector:enable
1+
//> using options -Ykind-projector
22

33
package kind_projector_neg
44

tests/pos/kind-projector.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//> using options -Ykind-projector:enable
1+
//> using options -Ykind-projector
22

33
package kind_projector
44

0 commit comments

Comments
 (0)