[#429] | project: compiler | priority: low | category: bug | |
---|---|---|---|---|
submitter | assigned to | status | date submitted | |
Philippe | Martin | fixed | 2005-05-03 14:09:40.0 | |
subject | The analyzer transforms constant fields into constant functions | |||
code |
object Test { abstract class A { Console.print("A"); val x: Int; val y: Int = {Console.print("y"); x + 1} } class B extends A { Console.print("B"); val x = 4; } def main (args: Array[String]): Unit = { Console.print((new B).y); } } |
|||
what happened | The program prints |
|||
what expected | It should print |
|||
[back to overview] |
Martin edited on 2006-03-30 15:19:12.0 |
The reason why it prints this is actually a different one: Because the definition of `x' does not refer to `this' it is move to before the superclass constructor call. If we change the definition of `x' to val z = 0; val x = 4 + z Then AyB1 will be printed. It's probably still a bug though, we should not move value definitions unless they are proxies for parameters. -- Martin |
Martin edited on 2006-05-27 11:38:52.0 |