Aladdin - Scala Bugtracking
[#49] project: compiler priority: medium category: bug
submitter assigned to status date submitted
Damien Michel fixed 2003-06-30 09:49:18.0
subject addAccessor assertion failed
code
class M(f: Int=>Int);
object o {
  val a = { class N extends M((x:Int)=>x+1); ((new N):M) }
}

/*
// this compiles
class M(f: Int);
object o {
  val a = { class N extends M(1); ((new N):M) }
}

// this too
class M(f: Int=>Int);
object o {
  val a = new M((x:Int)=>x+1)
}
*/
what happened
Exception in thread "main" java.lang.AssertionError
        at scalac.transformer.AddAccessors.transform(AddAccessors.java:103)
        at scalac.ast.Transformer.transform(Transformer.java:252)
        at scalac.ast.Transformer.transform(Transformer.java:153)
        at scalac.transformer.AddAccessors.transform(AddAccessors.java:149)
        at scalac.ast.Transformer.transform(Transformer.java:252)
        at scalac.ast.Transformer.transform(Transformer.java:193)
        at scalac.transformer.AddAccessors.transform(AddAccessors.java:149)
        at scalac.ast.Transformer.transform(Transformer.java:252)
        at scalac.transformer.AddAccessors.transform(AddAccessors.java:105)
        at scalac.ast.Transformer.transform(Transformer.java:257)
        at scalac.transformer.AddAccessors.transform(AddAccessors.java:67)
        at scalac.ast.Transformer.transform(Transformer.java:257)
        at scalac.ast.Transformer.apply(Transformer.java:71)
        at scalac.ast.Transformer.apply(Transformer.java:66)
        at scalac.ast.Transformer.apply(Transformer.java:62)
        at scalac.transformer.AddAccessorsPhase.apply(AddAccessorsPhase.java:31)
        at scalac.Global.compile(Global.java:269)
        at scalac.Global.compile(Global.java:245)
        at scalac.Main.main(Main.java:32)
what expected empty output :)
[back to overview]
Changes of this bug report
Michel  edited on  2003-06-30 09:49:18.0
This seems to be more a problem with lambda lifting, which doesn't lift the (implicit) class declaration introduced by the anonymous function in the call to M's constructor. The following example illustrates this more clearly:
class C1(x: Object) {};

class C2 extends C1({ class A extends Object {}; (new A) : Object }) {};
In my opinion, LambdaLift should lift the definition of class A to the same level as C2, because this definition does not happen in the context of C2, but really in the context of its constructor, i.e. a function.
Martin  edited on  2003-07-04 16:24:12.0
I fixed so that now the inner class is lifted. However I get (for Michel's simplified example): Exception in thread "main" java.lang.AssertionError: A$0 is interface at scalac.transformer.AddConstructors.getConstructor(AddConstructors.java:84) at scalac.transformer.AddConstructors.getConstructor(AddConstructors.java:73) at scalac.transformer.AddConstructors.transform(AddConstructors.java:238) at scalac.ast.Transformer.transform(Transformer.java:203) at scalac.transformer.AddConstructors.transform(AddConstructors.java:249) at scalac.ast.Transformer.transform(Transformer.java:190) at scalac.transformer.AddConstructors.transform(AddConstructors.java:249) at scalac.ast.Transformer.transform(Transformer.java:193) at scalac.transformer.AddConstructors.transform(AddConstructors.java:249) at scalac.ast.Transformer.transform(Transformer.java:252) at scalac.ast.Transformer.transform(Transformer.java:153) at scalac.transformer.AddConstructors.transform(AddConstructors.java:249) at scalac.ast.Transformer.transform(Transformer.java:252) at scalac.transformer.AddConstructors.transform(AddConstructors.java:171) at scalac.ast.Transformer.transform(Transformer.java:257) at scalac.ast.Transformer.apply(Transformer.java:71) at scalac.ast.Transformer.apply(Transformer.java:66) at scalac.ast.Transformer.apply(Transformer.java:62) at scalac.transformer.AddConstructorsPhase.apply(AddConstructorsPhase.java:36) at scalac.Global.compile(Global.java:268) at scalac.Global.compile(Global.java:244) at scalac.Main.main(Main.java:32)
Nikolay  edited on  2003-07-10 15:50:17.0
Reassigned to Michel:
It seems that (for Michel's example) AddInterfaces does not substitute the new A$0() expression with new A$0$class().
Michel  edited on  2003-07-10 16:27:20.0