I think it is in the SLS 9.2.
"Selections p.m from p as well as imports from p work as for objects.
However, unlike
other objects, packages may not be used as values. It is illegal to
have a package with
the same fully qualified name as a module or a class.
Top-level definitions outside a packaging are assumed to be injected
into a special
empty package. That package cannot be named and therefore cannot be
imported.
However, members of the empty package are visible to each other
without qualification."
package p {
package base {
}
object base {
}
}
Fully qualified names are both _root_.p.base so it is already
ambiguous. There is no way to do an import without ambiguity.
package base {
}
object base {
}
IIUC: Fully qualified name are also both _root_.base.
but the object base is automatically imported and in scope and the
package base not.
base nad import base._ refers to object base
If you do try to import with the fully qualified name _root_.base then
the import is ambiguous.
object base {
class X { println("class X in object base") }
}
package base {
class X { println("class X in package base") }
}
object Main extends App {
import base._ // doesn't matter
new base.X
}
C:\scala-2.10.0-M4\myexamples2>scalac namingclash.scala
C:\scala-2.10.0-M4\myexamples2>scala Main
class X in object base
object base {
class X { println("class X in object base") }
}
package base {
class X { println("class X in package base") }
}
object Main extends App {
import _root_.base._
new base.X // ambiguity
}
C:\scala-2.10.0-M4\myexamples2>scalac namingclash.scala
namingclash.scala:38: error: reference to base is ambiguous;
it is both defined in package <empty> and imported subsequently by
import _root_.base._
new base.X // ambiguity
^
one error found