Skip to content

Commit dab2777

Browse files
committed
Delete redundantly warning for list options
1 parent 8167d0d commit dab2777

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

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

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -254,28 +254,26 @@ object Settings:
254254

255255
def setMultivalue(arg: String, args: List[String]) =
256256
val split = arg.split(",").toList
257-
// check whether a value was previously set
258-
def checkRedundant(actual: List[String]) =
259-
if changed then
260-
var dangers: List[String] = Nil
261-
val current = valueIn(sstate).asInstanceOf[List[String]]
262-
for value <- split if current.contains(value) do
263-
dangers :+= s"Setting $name set to $value redundantly"
264-
dangers.foldLeft(update(current ++ actual, arg, args))((sum, w) => sum.warn(w))
265-
else
266-
update(actual, arg, args)
257+
def setOrUpdate(actual: List[String]) =
258+
val updated =
259+
if changed then
260+
val current = valueIn(sstate).asInstanceOf[List[String]]
261+
current ++ actual
262+
else
263+
actual
264+
update(updated, arg, args)
267265
choices match
268266
case Some(choices) =>
269267
split.partition(choices.contains) match
270-
case (_, Nil) => checkRedundant(split)
268+
case (_, Nil) => setOrUpdate(split)
271269
case (valid, invalid) =>
272270
legacyChoices match
273271
case Some(legacyChoices) =>
274272
invalid.filterNot(legacyChoices.contains) match
275-
case Nil => checkRedundant(valid) // silently ignore legacy choices
273+
case Nil => setOrUpdate(valid) // silently ignore legacy choices
276274
case invalid => invalidChoices(invalid)
277275
case none => invalidChoices(invalid)
278-
case none => checkRedundant(split)
276+
case none => setOrUpdate(split)
279277

280278
def matches: Boolean =
281279
val name = arg.takeWhile(_ != ':')

compiler/test/dotty/tools/dotc/config/ScalaSettingsTests.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class ScalaSettingsTests:
5858
assertTrue("Has the feature", set.contains("implicitConversions"))
5959
assertTrue("Has the feature", set.contains("dynamics"))
6060

61-
@Test def `Warn if multistring element is supplied multiply`: Unit =
61+
@Test def `Don't warn if multistring element is supplied multiply`: Unit =
6262
class SUT extends SettingGroup:
6363
val language: Setting[List[String]] = MultiStringSetting(RootSetting, "language", "feature", "Enable one or more language features.")
6464
val sut = SUT()
@@ -67,7 +67,7 @@ class ScalaSettingsTests:
6767
val res = sut.processArguments(sumy, processAll = true, skipped = Nil)
6868
val set = sut.language.valueIn(res.sstate)
6969
assertEquals(3, args.length)
70-
assertEquals("Must warn", 1, res.warnings.length)
70+
assertTrue("Mustn't warn", res.warnings.isEmpty)
7171
assertTrue("No errors!", res.errors.isEmpty)
7272
assertTrue("Has the feature", set.contains("implicitConversions"))
7373
assertTrue("Has the feature", set.contains("dynamics"))

tests/neg/no-patches.check

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
Flag -Yno-stdlib-patches set repeatedly
21
-- Error: tests/neg/no-patches.scala:3:23 ------------------------------------------------------------------------------
32
3 |val _ = scala.language.`3.4` // error: we do not patch `scala.language`
43
| ^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)