From 891862ccbc48d58647355aab2618c2a76bc7502e Mon Sep 17 00:00:00 2001 From: kenji yoshida <6b656e6a69@gmail.com> Date: Tue, 26 Dec 2023 12:14:17 +0900 Subject: [PATCH] add `case` in for comprehension. prepare Scala 3.4 https://github.com/lampepfl/dotty/commit/849ee9c07cf16f7199ab58348540c169eaa4dcac ``` Welcome to Scala 3.4.0-RC1 (1.8.0_392, Java OpenJDK 64-Bit Server VM). Type in expressions for evaluation. Or try :help. scala> for((f, true) <- List.empty[(Int, Boolean)]) yield f -- Error: ---------------------------------------------------------------------- 1 |for((f, true) <- List.empty[(Int, Boolean)]) yield f | ^^^^ |pattern's type (true : Boolean) is more specialized than the right hand side expression's type Boolean | |If the narrowing is intentional, this can be communicated by adding the `case` keyword before the full pattern, |which will result in a filtering for expression (using `withFilter`). 1 error found ``` ``` Welcome to Scala 3.3.1 (1.8.0_392, Java OpenJDK 64-Bit Server VM). Type in expressions for evaluation. Or try :help. scala> for((f, true) <- List.empty[(Int, Boolean)]) yield f 1 warning found -- Warning: -------------------------------------------------------------------- 1 |for((f, true) <- List.empty[(Int, Boolean)]) yield f | ^^^^ |pattern's type (true : Boolean) is more specialized than the right hand side expression's type Boolean | |If the narrowing is intentional, this can be communicated by adding the `case` keyword before the full pattern, |which will result in a filtering for expression (using `withFilter`). val res0: List[Int] = List() ``` --- io/src/main/scala/sbt/io/IO.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/io/src/main/scala/sbt/io/IO.scala b/io/src/main/scala/sbt/io/IO.scala index bdd28035..802f98ae 100644 --- a/io/src/main/scala/sbt/io/IO.scala +++ b/io/src/main/scala/sbt/io/IO.scala @@ -558,7 +558,7 @@ object IO { isEmpty.getOrElseUpdate(f, dirs(f) && f.isDirectory && (f.listFiles forall visit)) dirs foreach visit - for ((f, true) <- isEmpty) f.delete + for (case (f, true) <- isEmpty) f.delete } /** Deletes each file or directory (recursively) in `files`. */