Aladdin - Scala Bugtracking
[#737] project: compiler priority: high category: bug
submitter assigned to status date submitted
Sean Martin not repro 2006-09-09 16:26:21.0
subject more separate compilation and mixin problems
code
// Two files
// presentation/AutoEdit.scala
package presentation;

trait AutoEdit {
  type Node <: NodeImpl;
  trait NodeImpl {
    protected def indentAsAnchor : String;
    def autoEdit = {}
  }
  trait NewLineImpl extends NodeImpl {
    override def autoEdit = {
      super.autoEdit;
      Console.println("Hello ");
    }
  }
}
// scalax/ScalaTestXX.scala
package scalax;
import presentation._;

trait ScalaAutoEditXX extends AutoEdit {
  type Node <: NodeImpl;
  trait NodeImpl extends super[AutoEdit].NodeImpl  {
    def self : Node;
    override def indentAsAnchor = {
      null
    }
  }
  type NewLine <: Node with NewLineImpl;
  trait NewLineImpl extends super[AutoEdit].NewLineImpl with NodeImpl {
    def self : NewLine;
  }
}

trait ScalaParserAutoEditXXX extends ScalaAutoEditXX {
  type Node <: NodeImpl;
  trait NodeImpl extends super.NodeImpl {
    def self : Node;
    def isSemi = false; ;
  }
  type NewLine <: Node with NewLineImpl;
  trait NewLineImpl extends super.NewLineImpl with NodeImpl {
    override def isSemi = true; 
    def self : NewLine;
  }
}

trait ScalaTestXX extends ScalaParserAutoEditXXX {
  trait Node extends NodeImpl;
  class NewLine extends NewLineImpl with Node {
    def self = this;
  }
}
object test extends ScalaTestXX with Application {
  (new NewLine).autoEdit;
}

what happened
sean-mcdirmids-computer:~/workspace/test12/src mcdirmid$ ../../scala/build/quick/bin/scalac -XinnerClasses -d ..\
/bin -sourcepath . scalax/ScalaTestXX.scala presentation/AutoEdit.scala 
sean-mcdirmids-computer:~/workspace/test12/src mcdirmid$ ../../scala/build/quick/bin/scala -classpath ../bin sca\
lax.test
Hello 
sean-mcdirmids-computer:~/workspace/test12/src mcdirmid$ ../../scala/build/quick/bin/scalac -XinnerClasses -d ..\
/bin -sourcepath . scalax/ScalaTestXX.scala
sean-mcdirmids-computer:~/workspace/test12/src mcdirmid$ ../../scala/build/quick/bin/scala -classpath ../bin sca\
lax.test
When ScalaTestXX.scala is compiled alone, the wrong autoEdit method (AutoEdit.NodeImpl) is being called for NewL\ ine.autoEdit. The correct autoEdit method is in AutoEdit.NewLineImpl, which is called for NewLine.autoEdit if th\ e two files are compiled together.
what expected This is a really bad bug, it took me a half an afternoon to figure out :p
[back to overview]
Changes of this bug report
Martin  edited on  2006-09-12 12:24:51.0
This seems to have been fioxed by the latest changed I did to ExplicitOuter. Sean, can you verify this?