Aladdin - Scala Bugtracking
[#390] project: compiler priority: high category: bug
submitter assigned to status date submitted
Michel Martin fixed 2004-12-17 09:49:04.0
subject LambdaLift doesn't consider values appearing in types when lifting
code
class Outer { class Inner; }

object Main {
  def f: Unit = {
    val o = new Outer;
    { x: o.Inner => () } (null)
  }
}
what happened

(note: this bug is related to #362)

LambdaLift didn't pass the o variable to the anonymous class created for the closure, despite the f\ act that it appears in the type parameter passed to Function1. Here is what (parts of) the code loo\ ks like after LambdaLift:

  final def f(): scala.Unit = {
    final val o :Outer = new Outer();
    {
      (new Main.this.$anon$0()) : (o.Inner) => scala.Unit
    }.apply(null)
  };
  final class $anon$0() extends java.lang.Object() with scala.Function1[o.Inner, scala.Unit]() {
    final def apply(final x: o.Inner): scala.Unit = ();
  }
Here we see that o is used in several types in the $anon$0 class, but is not in scope \ at this point.
what expected

LambdaLift should add o to the value parameters given to the $anon$0 class, in order for it to be visible there, and the various types to be valid. Notice that this would trigger bug #362, but these are two different issues, I think.

I've set the priority of this bug to medium, as it currently makes it impossible for me to compile scalap with run time types enabled.

[back to overview]
Changes of this bug report
Michel  edited on  2005-01-25 13:42:57.0
Set the priority to high, as this is one of the last problems which prevent scalatest from working with run time types (the other two are: arrays and static methods in the interpreter).
Martin  edited on  2006-03-30 18:35:11.0
Fixed in version 2, because lifting appears after erasure