Closed
Description
class Foo {
(x: Int) => x + 1
}
A closure that is not a SAM will desugar to something like this in Dotty:
class Foo {
def apply(x: Int) = x + 1
class $anon extends Function1[Int, Int] {
def apply(x: Int) = Foo.this.apply(x)
}
new $anon
}
and this in scalac:
class Foo {
class $anon extends Function1[Int, Int] {
def apply(x: Int) = x + 1
}
new $anon
}
The issue with the Dotty desugaring, is that $anon
will capture a reference to the outer class Foo
that is not needed