To recap, it's been conjectured that we can get the performance benefit of
MHs without MHs, relying instead on two small changes:
- in the way uncurry lowers closures, and
- in the way closures are inlined, in the experimental optimizer
I built a prototype for the first step above, and stumbled upon a test not
passing. After reformulating it, I noticed the compiler crashes also
without my patch, thus this question.
The test that passes, run/t0911
class Foo(val bar : () => String);
class IP extends {
val baz = "bar";
} with Foo(() => baz);
object Test extends App{
(new IP).bar();
}
Manually expanding the "() => baz", we get the following which crashes the
compiler. As can be seen, the only change involves the additional "def
poorMansMH1(): String = baz;" and its invocation in the closure's apply():
class Foo(val bar : () => String);
class IP extends {
val baz = "bar";
} with Foo( {
def poorMansMH1(): String = baz;
@SerialVersionUID(0) final class anonfun extends
scala.runtime.AbstractFunction0[String] with Serializable {
def apply(): String = poorMansMH1()
};
new anonfun()
}
);
object Test extends App{
(new IP).bar();
}
Is this an implementation restriction, or am I doing something wrong?
Miguel
http://lampwww.epfl.ch/~magarcia/ScalaCompilerCornerReloaded/