Aladdin - Scala Bugtracking
[#204] project: compiler priority: medium category: bug
submitter assigned to status date submitted
Vincent Martin fixed 2003-10-20 16:27:47.0
subject def param & object in object
code
object a {
  def f(def x: unit) = ();
  object b { def g = f({}); }
}
what happened
At compile time:
Exception in thread "main" java.lang.AssertionError: ()a$b$ -> java.lang.Object
        at scalac.backend.jvm.GenJVM.genWidenConversion(GenJVM.java:960)
        at scalac.backend.jvm.GenJVM.genLoad(GenJVM.java:560)
...
what expected Silent compilation.
[back to overview]
Changes of this bug report
Michel  edited on  2003-10-21 11:04:14.0
This appears to be a bug in LambdaLift which doesn't add an Apply node where it should. Here is a slightly less complex example which exhibits the same problem:
class A {
  object B {
    def f() = {
      class C extends A {}; new C : A
    }
  }
}
The important part is the new C : A call. Before LambdaLift, it looks like this (with -uniqid):
class A#0() extends scala#1.Object#2() {
  final class B#8() extends scala#1.Object#2() {
    final def f#4(): A#0 = {
      class C#5() extends A#6() {
      };
      (new C#7()) : A#0
    }
  };
  private var B$#9: A#0.this.B#8 = null#10;
  final def B#3(): A#0.this.B#8 = {
    if (null#10.$eq$eq#11(A#0.this.B$#9))
      A#0.this.B$#9 = new A#0.this.B#12()
    else
       {
        
      };
    A#0.this.B$#9
  };
  private def B_$eq#13(B#14: A#0.this.B#8): scala#1.Unit#15 = A#0.this.B$#9 = B#14
};
and after LambdaLift, it looks like this:
class A#0() extends scala#1.Object#2() {
  final class B#8() extends scala#1.Object#2() {
    final def f#4(): A#0 = {
       (new A#0.this.B#3.C$0#7()) : A#0
    };
    class C$0#5() extends A#6() {
    }
  };
  private var B$#9: A#0.this.B#8 = null#10;
  final def B#3(): A#0.this.B#8 = {
    if (null#10.$eq$eq#11(A#0.this.B$#9))
      A#0.this.B$#9 = new A#0.this.B#12()
    else
       {
        
      };
    A#0.this.B$#9
  };
  private def B_$eq#13(B#14: A#0.this.B#8): scala#1.Unit#15 = A#0.this.B$#9 = B#14
};
which is wrong, since there is no (empty) parameter section given to B#3 even though it is a function.
Martin  edited on  2003-10-21 14:59:46.0
I changed TreeGen.mkStableId to add an Apply node if necessary. This corrects the problem in all code which uses TreeGen.mkRef (LambdaLift was one example).