From 3d4b02e4f3bd6a2170b8530956805774398f6684 Mon Sep 17 00:00:00 2001
From: Som Snytt <som.snytt@gmail.com>
Date: Fri, 6 Nov 2020 13:45:18 -0800
Subject: [PATCH 1/2] Vulpix preserves language flags

---
 .../test/dotty/tools/vulpix/TestFlags.scala   | 21 ++++++++++---------
 tests/neg-custom-args/i5498-postfixOps.scala  |  2 +-
 tests/pos-custom-args/i5498-postfixOps.scala  |  4 ++--
 3 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/compiler/test/dotty/tools/vulpix/TestFlags.scala b/compiler/test/dotty/tools/vulpix/TestFlags.scala
index d7ffc9ac7982..d9b21aafbd3a 100644
--- a/compiler/test/dotty/tools/vulpix/TestFlags.scala
+++ b/compiler/test/dotty/tools/vulpix/TestFlags.scala
@@ -27,22 +27,23 @@ final case class TestFlags(
   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) = {
+  //      https://github.com/lampepfl/dotty/issues/9787 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))
-  }
+    val existingFeatures = languageFeatures.flatMap(_.stripPrefix(languageFeatureFlag).split(","))
+    val featurePrefix =
+      if existingFeatures.isEmpty then ""
+      else existingFeatures.mkString(",") + ","
+    copy(options = rest ++ Array(languageFeatureFlag + featurePrefix + 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
+}

From 8096394b7485518747a57e43897fd8afca158775 Mon Sep 17 00:00:00 2001
From: Som Snytt <som.snytt@gmail.com>
Date: Fri, 6 Nov 2020 13:48:10 -0800
Subject: [PATCH 2/2] Vulpix simply adds language flags

---
 compiler/test/dotty/tools/vulpix/TestFlags.scala | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/compiler/test/dotty/tools/vulpix/TestFlags.scala b/compiler/test/dotty/tools/vulpix/TestFlags.scala
index d9b21aafbd3a..0037d5f551fe 100644
--- a/compiler/test/dotty/tools/vulpix/TestFlags.scala
+++ b/compiler/test/dotty/tools/vulpix/TestFlags.scala
@@ -26,15 +26,8 @@ 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/issues/9787 is implemented
   def andLanguageFeature(feature: String) =
-    val (languageFeatures, rest) = options.partition(_.startsWith(languageFeatureFlag))
-    val existingFeatures = languageFeatures.flatMap(_.stripPrefix(languageFeatureFlag).split(","))
-    val featurePrefix =
-      if existingFeatures.isEmpty then ""
-      else existingFeatures.mkString(",") + ","
-    copy(options = rest ++ Array(languageFeatureFlag + featurePrefix + feature))
+    copy(options = options ++ Array(s"$languageFeatureFlag$feature"))
 
   def withoutLanguageFeature(feature: String) =
     val (languageFeatures, rest) = options.partition(_.startsWith(languageFeatureFlag))