Closed
Description
Compiler version
3.0.0-RC2
Minimized code
import scala.compiletime.error
object BadFilters {
inline def withFilter(f: Int => Boolean): BadFilters.type = error("Unexpected withFilter call")
def foreach(f: Int => Unit): Unit = f(42)
}
@main def works =
for {
x: Int <- BadFilters
} println(x)
@main def breaks =
for {
given Int <- BadFilters
} println(summon[Int])
Output
Fails to compile breaks
with Unexpected withFilter call
Expectation
Compiles and prints:
42
42
The pattern x: Int
is considered exhaustive, causing withFilter
to not be emitted in works
, while the pattern given Int
isn't, so withFilter
is emitted and breaks
breaks.