Aladdin - Scala Bugtracking
[#595] project: compiler priority: low category: bug
submitter assigned to status date submitted
Sean Martin fixed 2006-05-15 17:40:49.0
subject package name weirdness
code
Given an explicit or implicit import of a package named lampion.scala:

Outside of lampion.scala:

import lampion.scala._;
import scala.collection._;

Inside lampion.scala

class Foo;

what happened
Former case: cannot find collection in lampion.scala. Latter case: cannot find ScalaObject in lampion.scala.
what expected Package system should be a bit saner. I have no idea why I'm getting these errors. Its probably because I decided to name a package lampion.scala, where its getting confused by "scala". It seems to be a bug though, because there is enough information to disambiguate (e.g., we are not importing lampion.scala, just the members of lampion.scala).
[back to overview]
Changes of this bug report
Sean  edited on  2006-05-15 17:45:09.0
Even worse than I thought. You don't have to import lampion.scala._ for things to blow up, just being in the lampion package is enough for an auto-import of lampion.scala (but not its members) to occur! So Scala will always favor xxx.yyy over yyy if we are in some sub-package xxx, yikes!
Martin  edited on  2006-05-17 10:57:51.0
First, implicitly added references such as scala.ScalaObject can no longer be hijacked by package statements. Second, there is now a new package name _root_, from which absolute package names can be constructed. E.g.
package lampion.scala
import _root_.scala.collection.mutable._
Burak  edited on  2006-06-02 15:48:16.0
I just made the SymbolicXMLBuilder use the _root_ so that one can also use XML literals in a scope that rebinds the "scala" name. The (not minimal) example is here
object markupstuff {
  object in {
    object scala {
      val XML = _root_.scala.xml.XML;

      val foo = <a><b/></a>
    }
  }
}