Closed
Description
Compiler version
Problem observed on 3.3.1. The problem started with 3.1.2, whereas 3.1.1 works fine. (according to scastie)
Minimized code
trait Printable {
def pprint(v: () => String): Unit = {
println(v())
}
}
extension (ctx: Printable)
def pprint(f: () => Int): Unit = {
ctx.pprint(() => f().toString)
}
val x = new Printable {}
def test =
x.pprint(() => "hello") // ok
x.pprint(() => { "hello" }) // ok
x.pprint(() => 123) // ok
x.pprint(() => ( 123 )) // ok
x.pprint(() => { 123 }) // FAIL
https://scastie.scala-lang.org/ShYSWt7NSnusCJKuCu8OOw
Output
In Scala 3.3.1 and as early as 3.1.2, this line: x.pprint(() => { 123 })
causes compiler error:
Found: (123 : Int)
Required: String
Whereas in Scala 3.1.1, that line compiles fine.
Expectation
x.pprint(() => { 123 })
should compile, consistently with other similar usages shown in the code snippet.