diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-12-17 17:47:15 +0100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2013-12-18 14:29:17 +0100 |
commit | 7e85b595502974bebf2f2625c6bc3645f0d3ab27 (patch) | |
tree | 842325683b4d5458e1ae639718a75c3bc32d25f7 /src/compiler | |
parent | a12dd9c3b6fb4a767eec8f6d3bf0a9a2266eff85 (diff) | |
download | scala-7e85b595502974bebf2f2625c6bc3645f0d3ab27.tar.gz scala-7e85b595502974bebf2f2625c6bc3645f0d3ab27.tar.bz2 scala-7e85b595502974bebf2f2625c6bc3645f0d3ab27.zip |
SI-8085 Fix BrowserTraverser for package objects
A source file like:
import foo.bar
package object baz
Is parsed into:
package <empty> {
import foo.bar
package baz {
object `package`
}
}
A special case in Namers compensates by adjusting the owner of
`baz` to be `<root>`, rather than `<empty>`.
This wasn't being accounted for in `BrowserTraverser`, which
underpins `-sourcepath`, and allows the presentation compiler to
load top level symbols from sources outside those passes as
the list of sources to compile.
This bug did not appear in sources like:
package p1
package object p2 { ... }
... because the parser does not wrap this in the `package <empty> {}`
This goes some way to explaining why it has gone unnoticed for
so long.
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/BrowsingLoaders.scala | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/BrowsingLoaders.scala b/src/compiler/scala/tools/nsc/symtab/BrowsingLoaders.scala index f2aab36b51..c7bd678385 100644 --- a/src/compiler/scala/tools/nsc/symtab/BrowsingLoaders.scala +++ b/src/compiler/scala/tools/nsc/symtab/BrowsingLoaders.scala @@ -64,8 +64,10 @@ abstract class BrowsingLoaders extends SymbolLoaders { addPackagePrefix(pre) packagePrefix += ("." + name) case Ident(name) => - if (packagePrefix.length != 0) packagePrefix += "." - packagePrefix += name + if (name != nme.EMPTY_PACKAGE_NAME) { // mirrors logic in Namers, see createPackageSymbol + if (packagePrefix.length != 0) packagePrefix += "." + packagePrefix += name + } case _ => throw new MalformedInput(pkg.pos.point, "illegal tree node in package prefix: "+pkg) } |