Open
Description
Compiler version
3.7.0, 3.7.1-RC1, 3.7.2-RC1
Minimized example
//> using scala "3.7.2-RC1"
//> using options "-preview", "-Vprint:typer"
@main def main =
println:
for
a <- List(1)
b <- List(a)
yield b
For comparison, the same code with older compiler version:
//> using scala "3.6.4"
//> using options "-language:experimental.betterFors", "-Vprint:typer"
@main def main =
println:
for
a <- List(1)
b <- List(a)
yield b
Output
In 3.7.0, 3.7.1-RC1, 3.7.2-RC1 the trailing map is not removed:
@main def main: Unit =
println(
List.apply[Int]([1 : Int]*).flatMap[Int]((a: Int) =>
List.apply[Int]([a : Int]*).map[Int]((b: Int) => b))
)
In 3.6.4 the trailing map is removed:
@main def main: Unit =
println(
List.apply[Int]([1 : Int]*).flatMap[Int]((a: Int) =>
List.apply[Int]([a : Int]*))
)
Expectation
Have the trailing map removed.
Here is more complex case. The lack of trailing map removal causes 20% lower scores in this microbenchmark suite. Applies to all effect systems.