sbt / io

IO module for sbt
Apache License 2.0
41 stars 47 forks source link

add `case` in for comprehension. prepare Scala 3.4 #363

Closed xuwei-k closed 9 months ago

xuwei-k commented 9 months ago
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()