Compiler version
3.3.7, 3.7.4, 3.8.0-RC3, 3.nightly
Minimized code
//> using scala 3.8.0-RC3
trait A
trait B extends A {
def b: Boolean
}
def f() = {
val s = Seq[A]()
for (case x: B <- s if x.b) yield x
}
Output
[error] .\Main.scala:10:13
[error] Found: B => B
[error] Required: A => B
[error] for (case x: B <- s if x.b) yield x // this gives an error: Found B => B, Required A => B
[error] ^^^^^^^^^^^^^^^^^^^^^^^^^
Expectation
The code should compile. It compiles when closing x: B in parentheses as case (x: B). See also https://users.scala-lang.org/t/desugaring-of-for-with-pattern-match-and-if-guard/12147/2?u=ondrejspanel