Open retronym opened 8 years ago
Thinking about this some more, this change might need to be nuanced a little. The user might expect that the following works:
class C { def foo = { (x: Any) => "YO!" + x.toString) }
class Test1 extends App { save(serialize(new C().foo) })
% scalac test.scala && scala Test1
class C { def foo = { (x: Any) => x.toString) }
class Test2 extends App { deserialize(load() })
% scalac test.scala && scala Test2
However, if we to elide the anonFun
lambda implementation method on the second compilation of C
, we would be unable to deserialize.
A similar argument applies to the ability to reflect on the parameter names of lambdas, which is now supported with Java 8 lambdas (by looking at the parameter names of the non-capture arguments to the impl method).
As such, javac only seems to directly refer to the method called in the lambda when the method reference syntax is used.
When the body of a lambda or a SAM is just a "method reference", we could use that as the implementation method of the
LambdaMetaFactory
bootstrap, rather than emitting a wrapper method.Current: