Aladdin - Scala Bugtracking
[#747] project: compiler priority: high category: bug
submitter assigned to status date submitted
Sean Martin not repro 2006-09-20 21:15:16.0
subject Duplicate trait initialization
code
package test;

trait DefaultScanner {
  abstract class SingletonFactory(c : Char) {
    def init = Console.println("init: " + c);
  }
  abstract class PairFactory[T](val open : T, val close : T);
  trait BraceFactory extends PairFactory[Char] {
    object openF extends SingletonFactory(open);
    object closeF extends SingletonFactory(close);
    openF.init;
    closeF.init;
  }
}
trait ScalaScanner extends DefaultScanner {
  abstract class CurlyFactory extends BraceFactory('{', '}') {
    override def toString() = "curly";
  }
}
class ScalaTest extends ScalaScanner {
  object curlyFactory extends CurlyFactory;
}
object test {
  def main(args : Array[String]) : Unit = {
    val test = new ScalaTest;
    Console.println(test.curlyFactory);
  }
}
what happened
On execution: 
init: {
init: }
init: {
init: }
curly
The initializer in BraceFactory is being called twice.
what expected On execution:
init: {
init: }
curly
[back to overview]
Changes of this bug report
Martin  edited on  2006-09-20 22:22:01.0
this was already fixed in the latest check-in.