title: Why is my object not a member of package <root> if it's in a separate source file?
body: <p>I'm having a problem accessing an object defined in the root package.  If I have all my code in one file, it works fine, but when I split it across two files, I can't get it past the compiler.  </p>
  
  <p>This works fine:</p>
  
  <p>All in one file called <code>packages.scala</code>:</p>
  
  <pre><code>object Foo
    val name = "Brian"
  }
  
  package somepackage {
    object Test extends App {
      println(Foo.name)
    }
  }
  </code></pre>
  
  <p>Witness:</p>
  
  <pre><code>$ scalac packages.scala
  $ scala -cp . somepackage.Test
  Brian
  </code></pre>
  
  <p>But if I split the code across two files:</p>
  
  <p><code>packages.scala</code></p>
  
  <pre><code>object Foo {
    val name = "Brian"
  }
  </code></pre>
  
  <p><code>packages2.scala</code></p>
  
  <pre><code>package somepackage {
    object Test extends App {
      println(Foo.name)
    }
  }
  </code></pre>
  
  <p>it all fails:</p>
  
  <pre><code>$ scalac packages.scala packages2.scala
  packages2.scala:3: error: not found: value Foo
  </code></pre>
  
  <p>So I try to make the reference to <code>Foo</code> absolute:</p>
  
  <pre><code>...
      println(_root_.Foo.name)
  ...
  </code></pre>
  
  <p>But that doesn't work either:</p>
  
  <pre><code>$ scalac packages.scala packages2.scala
  packages2.scala:3: error: object Foo is not a member of package &lt;root&gt;
  </code></pre>
  
  <p>If <code>Foo</code> is not a member of the root package, where on earth <em>is</em> it?</p>