diff --git a/compiler/test/dotty/tools/vulpix/TestFlags.scala b/compiler/test/dotty/tools/vulpix/TestFlags.scala index d7ffc9ac7982..0037d5f551fe 100644 --- a/compiler/test/dotty/tools/vulpix/TestFlags.scala +++ b/compiler/test/dotty/tools/vulpix/TestFlags.scala @@ -26,23 +26,17 @@ final case class TestFlags( private val languageFeatureFlag = "-language:" private def withoutLanguageFeaturesOptions = options.filterNot(_.startsWith(languageFeatureFlag)) - // TODO simplify to add `-language:feature` to `options` once - // https://github.com/lampepfl/dotty-feature-requests/issues/107 is implemented - def andLanguageFeature(feature: String) = { - val (languageFeatures, rest) = options.partition(_.startsWith(languageFeatureFlag)) - val existingFeatures = if (languageFeatures.isEmpty) languageFeatures.mkString(",") + "," else "" - copy(options = rest ++ Array(languageFeatureFlag + existingFeatures + feature)) - } + def andLanguageFeature(feature: String) = + copy(options = options ++ Array(s"$languageFeatureFlag$feature")) - def withoutLanguageFeature(feature: String) = { + def withoutLanguageFeature(feature: String) = val (languageFeatures, rest) = options.partition(_.startsWith(languageFeatureFlag)) - val filteredFeatures = languageFeatures.filter(_ == feature) + val existingFeatures = languageFeatures.flatMap(_.stripPrefix(languageFeatureFlag).split(",")) + val filteredFeatures = existingFeatures.filterNot(_ == feature) val newOptions = - if (filteredFeatures.isEmpty) rest + if filteredFeatures.isEmpty then rest else rest ++ Array(languageFeatureFlag + filteredFeatures.mkString(",")) - copy(options = newOptions) - } /** Subset of the flags that should be passed to javac. */ def javacFlags: Array[String] = { diff --git a/tests/neg-custom-args/i5498-postfixOps.scala b/tests/neg-custom-args/i5498-postfixOps.scala index 2c02c2c62c5d..e6a3c5cbe7ff 100644 --- a/tests/neg-custom-args/i5498-postfixOps.scala +++ b/tests/neg-custom-args/i5498-postfixOps.scala @@ -4,4 +4,4 @@ def test() = { 1 second // error: usage of postfix operator Seq(1, 2).filter(List(1,2) contains) // error: usage of postfix operator -} \ No newline at end of file +} diff --git a/tests/pos-custom-args/i5498-postfixOps.scala b/tests/pos-custom-args/i5498-postfixOps.scala index bfde706b963b..c7c0fe82cd0a 100644 --- a/tests/pos-custom-args/i5498-postfixOps.scala +++ b/tests/pos-custom-args/i5498-postfixOps.scala @@ -5,5 +5,5 @@ import scala.language.postfixOps def test() = { 1 second - Seq(1, 2) filter (List(1,2) contains) -} \ No newline at end of file + Seq(1, 2) filter (List(1,2) contains) toList +}