Closed
Description
This is the same bug as scala/bug#1980:
class C {
def m2_:(f: => Int) = ()
}
object Test {
def foo() = { println("foo") ; 5 }
def main(args: Array[String]): Unit = {
val c = new C
foo() m2_: c
}
}
This should print nothing but ends up printing foo because we desugar:
foo() m2_: c
into:
val $1$: Int = Test.foo()
c.m2_:($1$)
In scalac this was basically unfixable because this desugaring is done during parsing, but in dotty we should have the type of m2_:
during desugaring which tells us that its argument is by-name and thus we could simply do:
lazy val $1$: Int = Test.foo()
c.m2_:($1$)
Whether or not this is fixed might influence the design of the collection strawman: scala/collection-strawman#127