aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/SymbolLoaders.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-02-07 13:19:58 +0100
committerMartin Odersky <odersky@gmail.com>2014-02-07 13:19:58 +0100
commit5bed5bdd1bb377e9a177a2be635b391bfc0f168e (patch)
tree155c964126b4b74aa5e0c61d4f9997c2efedbf76 /src/dotty/tools/dotc/core/SymbolLoaders.scala
parent5f5a01c4f74a40eb6d387b83302da2d3c413969b (diff)
downloaddotty-5bed5bdd1bb377e9a177a2be635b391bfc0f168e.tar.gz
dotty-5bed5bdd1bb377e9a177a2be635b391bfc0f168e.tar.bz2
dotty-5bed5bdd1bb377e9a177a2be635b391bfc0f168e.zip
Replace open package module logic by special member lookups in a package class.
Rather than fiddling with scopes, which can lead to race conditions, we now special case member lookup and mamber name filters in ClassDenotations that represent packages.
Diffstat (limited to 'src/dotty/tools/dotc/core/SymbolLoaders.scala')
-rw-r--r--src/dotty/tools/dotc/core/SymbolLoaders.scala44
1 files changed, 2 insertions, 42 deletions
diff --git a/src/dotty/tools/dotc/core/SymbolLoaders.scala b/src/dotty/tools/dotc/core/SymbolLoaders.scala
index 543b7cc1d..d88e84ff7 100644
--- a/src/dotty/tools/dotc/core/SymbolLoaders.scala
+++ b/src/dotty/tools/dotc/core/SymbolLoaders.scala
@@ -163,49 +163,9 @@ class SymbolLoaders {
if (maybeModuleClass(classRep) && !root.decls.lookup(classRep.name.toTypeName).exists)
initializeFromClassPath(root.symbol, classRep)
}
- if (!root.isEmptyPackage) {
- for (pkg <- classpath.packages) {
+ if (!root.isEmptyPackage)
+ for (pkg <- classpath.packages)
enterPackage(root.symbol, pkg)
- }
- openPackageModule(root.symbol.asClass)
- }
- }
- }
-
- /** if there's a `package` member object in `pkgClass`, enter its members into it. */
- def openPackageModule(pkgClass: ClassSymbol)(implicit ctx: Context): Unit = {
- val pkgModule = pkgClass.info.decl(nme.PACKAGEkw).symbol
- if ((pkgModule is Module) &&
- (pkgModule.isCompleted ||
- !pkgModule.completer.isInstanceOf[SourcefileLoader]))
- // println("open "+pkgModule)//DEBUG
- openPackageModule(pkgModule, pkgClass)
- }
-
- // todo: revise to really include the members?
- def openPackageModule(container: Symbol, dest: ClassSymbol)(implicit ctx: Context): Unit = {
- def isImportable(sym: Symbol) = !(sym is Private) && !sym.isConstructor
- // unlink existing symbols in the package
- for (member <- container.info.decls.iterator) {
- if (isImportable(member)) {
- // todo: handle overlapping definitions in some way: mark as errors
- // or treat as abstractions. For now the symbol in the package module takes precedence.
- for (existing <- dest.info.decl(member.name).alternatives)
- dest.delete(existing.symbol)
- }
- }
- // enter non-private decls in the class
- for (member <- container.info.decls.iterator) {
- if (isImportable(member)) {
- dest.enterNoReplace(member, dest.decls.asInstanceOf[MutableScope])
- }
- }
- // !!! TODO info.decls -> decls
- // enter decls of parent classes
- for (p <- container.info.parents) {
- if (p.symbol != defn.ObjectClass) {
- openPackageModule(p.symbol, dest)
- }
}
}
}